summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--jaildaemon.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/jaildaemon.c b/jaildaemon.c
index ae750f3..506ca98 100644
--- a/jaildaemon.c
+++ b/jaildaemon.c
@@ -349,11 +349,20 @@ int main( int argc, char **argv ) {
349 /* Start a fork slave while there is no file descriptors or initialized 349 /* Start a fork slave while there is no file descriptors or initialized
350 memory yet. Communicate with this slave via socketpair */ 350 memory yet. Communicate with this slave via socketpair */
351 if( o_daemonize ) { 351 if( o_daemonize ) {
352 if( daemon(0,0) == -1 ) 352 if( daemon(1,0) == -1 )
353 exerr( "daemonzing" ); 353 exerr( "daemonzing" );
354 g_fork_slave_fd = fork_fork_slave( ); 354 g_fork_slave_fd = fork_fork_slave( );
355 355
356 openlog( "jaildaemon", 0, LOG_DAEMON ); 356 /* When we're supposed to write a pidfile, just do it */
357 if( o_pidfile ) {
358 FILE *fp = fopen( o_pidfile, "w");
359 if (!fp)
360 exerr("opening pid file");
361 fprintf(fp, "%d\n", (int)getpid());
362 fclose(fp);
363 }
364
365 openlog( "jaildaemon", 0, LOG_DAEMON );
357 setlogmask(LOG_UPTO(LOG_INFO)); 366 setlogmask(LOG_UPTO(LOG_INFO));
358 g_whoami = IAM_DAEMON; 367 g_whoami = IAM_DAEMON;
359 368
@@ -363,7 +372,7 @@ int main( int argc, char **argv ) {
363 usage( argv[0] ); 372 usage( argv[0] );
364 } 373 }
365 374
366 /* Setup unix domain socket descriptors */ 375 /* Setup unix domain socket descriptors */
367 g_uds = socket(AF_UNIX, SOCK_DGRAM, 0); 376 g_uds = socket(AF_UNIX, SOCK_DGRAM, 0);
368 if( g_uds < 0 ) 377 if( g_uds < 0 )
369 exerr( "Can not create control channel." ); 378 exerr( "Can not create control channel." );