File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ function input_handler( event )
3737 os.execute ( " mpc next" ) -- F3
3838 end
3939
40- -- when this function returns "quit", the program exits
40+ -- when this function returns "quit", the device gets closed
4141 if event [1 ] == " 2" and event [2 ] == " 41" then
4242 return " quit" -- shift+esc : quit
4343 end
Original file line number Diff line number Diff line change @@ -22,12 +22,6 @@ The lua script that should be loaded.
2222.TP
2323\fB \- f \fR , \fB \-\- fork \fR
2424Fork into the background.
25- .TP
26- \fB \- u \fR , \fB \-\- user \fR =\fI NUMBER \fR
27- User id to drop privileges to, requires \fB \- g \fR .
28- .TP
29- \fB \- g \fR , \fB \-\- group \fR =\fI NUMBER \fR
30- Group id to drop privileges to, requires \fB \- u \fR .
3125.SH EXAMPLES
3226Start and run in the background
3327.PP
Original file line number Diff line number Diff line change @@ -412,6 +412,23 @@ int main( int argc, char *argv[] )
412412 return 1 ;
413413 }
414414
415+ // fork ?
416+ // **************************************************************
417+ if ( flag_fork )
418+ {
419+ // create child process
420+ pid_t process_id = fork ();
421+
422+ // close file descriptors
423+ close ( fileno (stdin) ); // cin
424+ close ( fileno (stdout) ); // cout
425+ close ( fileno (stdout) ); // cerr
426+
427+ // quit if not child process
428+ if ( process_id != 0 )
429+ return 0 ;
430+ }
431+
415432 // lua initialisation
416433 // **************************************************************
417434 lua_State *L = luaL_newstate (); // open lua
@@ -446,25 +463,7 @@ int main( int argc, char *argv[] )
446463 lua_remove ( L, -1 ); // remove top value from stack
447464 lua_close ( L );
448465 return 1 ;
449- }
450-
451- // fork ?
452- // **************************************************************
453- if ( flag_fork )
454- {
455- // create child process
456- pid_t process_id = fork ();
457-
458- // close file descriptors
459- close ( fileno (stdin) ); // cin
460- close ( fileno (stdout) ); // cout
461- close ( fileno (stdout) ); // cerr
462-
463- // quit if not child process
464- if ( process_id != 0 )
465- return 0 ;
466- }
467-
466+ }
468467 }
469468
470469 // wait for all threads to join
You can’t perform that action at this time.
0 commit comments