Skip to content

Commit e3085c6

Browse files
committed
Fix -f option, update manpage
1 parent eae7411 commit e3085c6

3 files changed

Lines changed: 19 additions & 26 deletions

File tree

example.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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

macrodevice-lua.1

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,6 @@ The lua script that should be loaded.
2222
.TP
2323
\fB\-f\fR, \fB\-\-fork\fR
2424
Fork into the background.
25-
.TP
26-
\fB\-u\fR, \fB\-\-user\fR=\fINUMBER\fR
27-
User id to drop privileges to, requires \fB\-g\fR.
28-
.TP
29-
\fB\-g\fR, \fB\-\-group\fR=\fINUMBER\fR
30-
Group id to drop privileges to, requires \fB\-u\fR.
3125
.SH EXAMPLES
3226
Start and run in the background
3327
.PP

macrodevice-lua.cpp

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)