7
#include <emscripten.h>
12
void main_loop(void *arg)
18
while (errno != EAGAIN) {
21
if (ret != EOF) putc(ret, stdout);
22
if (ret == '\n') line++;
23
} else if (line > 0) {
24
ret = scanf("%10s", str);
25
if (ret > 0) puts(str);
28
if (ferror(stdin) && errno != EAGAIN) {
42
int main(int argc, char const *argv[])
44
fcntl(STDIN_FILENO, F_SETFL, O_NONBLOCK);
46
// SM shell doesn't implement an event loop and therefor doesn't support
47
// emscripten_set_main_loop. However, its stdin reads are sync so it
48
// should exit out after calling main_loop once.
52
emscripten_set_main_loop(main_loop, 60, 0);
54
while (1) main_loop(NULL); sleep(1);
b'\\ No newline at end of file'