diff options
author | erdgeist <> | 2013-03-02 00:55:15 +0000 |
---|---|---|
committer | erdgeist <> | 2013-03-02 00:55:15 +0000 |
commit | 0abb27e6e3a5eff43b4dfcc0455aa414a0837ed5 (patch) | |
tree | e96d7e6497476b8c2e99d3bc4e247f270b926837 | |
parent | 0cbc47bfd9a52d6e2d0dd1ae245305fb59f61760 (diff) |
Ensure that the jaildaemon dies when its fork slave is gone
-rw-r--r-- | jaildaemon.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/jaildaemon.c b/jaildaemon.c index 797f547..ae750f3 100644 --- a/jaildaemon.c +++ b/jaildaemon.c | |||
@@ -456,6 +456,12 @@ int main( int argc, char **argv ) { | |||
456 | EV_SET( &ke, g_uds, EVFILT_VNODE, EV_ADD, NOTE_DELETE | NOTE_LINK, 0, 0); | 456 | EV_SET( &ke, g_uds, EVFILT_VNODE, EV_ADD, NOTE_DELETE | NOTE_LINK, 0, 0); |
457 | kevent( kq, &ke, 1, NULL, 0, NULL ); | 457 | kevent( kq, &ke, 1, NULL, 0, NULL ); |
458 | 458 | ||
459 | /* We want to be notified if the fork slave died. This is a good time to | ||
460 | die, too*/ | ||
461 | EV_SET( &ke, g_fork_slave_fd, EVFILT_READ, EV_ADD, 0, 0, 0); | ||
462 | kevent( kq, &ke, 1, NULL, 0, NULL ); | ||
463 | |||
464 | |||
459 | /* If daemon was started with some initial script, fire it now | 465 | /* If daemon was started with some initial script, fire it now |
460 | -- this leaks some information in the command line to all jails and | 466 | -- this leaks some information in the command line to all jails and |
461 | thus is disabled | 467 | thus is disabled |
@@ -554,6 +560,15 @@ int main( int argc, char **argv ) { | |||
554 | 560 | ||
555 | /* Takes a copy of our task and all string members */ | 561 | /* Takes a copy of our task and all string members */ |
556 | add_task_to_kqueue( kq, &task ); | 562 | add_task_to_kqueue( kq, &task ); |
563 | } else if( (int)ke.ident == g_fork_slave_fd ) { | ||
564 | /* If we see activity on the socket to the fork slave in | ||
565 | this place, that can only mean that the slave died (EOF), | ||
566 | or that something strange is going on over there. For now | ||
567 | we only warn, we may switch to exerr() in the future. */ | ||
568 | if( ke.flags == EV_EOF ) | ||
569 | exerr( "Fork slave died. We die, too." ); | ||
570 | else | ||
571 | warn( "Spurious packet from fork slave." ); | ||
557 | } | 572 | } |
558 | break; | 573 | break; |
559 | case EVFILT_VNODE: | 574 | case EVFILT_VNODE: |