Skip to content

Commit 112af09

Browse files
committed
Fix for run in background on Raspberry Pi
1 parent ef72d86 commit 112af09

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/platform/web/main.cpp

+7-2
Original file line numberDiff line numberDiff line change
@@ -315,15 +315,20 @@ int main(int argc, char **argv) {
315315
sbasic_main(runBas);
316316
puts(g_canvas.getPage().c_str());
317317
} else {
318-
fprintf(stdout, "Starting SmallBASIC web server on port:%d\n", port);
318+
fprintf(stdout, "Starting SmallBASIC web server on port:%d. Press return to exit.\n", port);
319319
MHD_Daemon *d = MHD_start_daemon(MHD_USE_INTERNAL_POLLING_THREAD, port,
320320
&accept_cb, nullptr,
321321
&access_cb, nullptr, MHD_OPTION_END);
322322
if (d == nullptr) {
323323
fprintf(stderr, "startup failed\n");
324324
return 1;
325325
}
326-
getc(stdin);
326+
327+
while(getc(stdin) != '\n') {
328+
usleep(10000); // On Raspberry Pi OS getc returns immediately EOF if in background.
329+
// Sleep to reduce cpu usage.
330+
}
331+
327332
MHD_stop_daemon(d);
328333
}
329334
free(execBas);

0 commit comments

Comments
 (0)