diff options
author | Michael K. Johnson <johnsonm@redhat.com> | 1999-12-06 16:59:19 +0000 |
---|---|---|
committer | Michael K. Johnson <johnsonm@redhat.com> | 1999-12-06 16:59:19 +0000 |
commit | e4cbbdca8761ce2467c0bb171e2fc695e2842be5 (patch) | |
tree | fd34c4774e44e2c214785718bbbe3316f8abca4e /src/ppp-watch.c | |
parent | 89dca649785a919576aa4b830969bba63ee89139 (diff) | |
download | initscripts-e4cbbdca8761ce2467c0bb171e2fc695e2842be5.tar initscripts-e4cbbdca8761ce2467c0bb171e2fc695e2842be5.tar.gz initscripts-e4cbbdca8761ce2467c0bb171e2fc695e2842be5.tar.bz2 initscripts-e4cbbdca8761ce2467c0bb171e2fc695e2842be5.tar.xz initscripts-e4cbbdca8761ce2467c0bb171e2fc695e2842be5.zip |
handle control-C and such on parent right
use sigaction
Diffstat (limited to 'src/ppp-watch.c')
-rw-r--r-- | src/ppp-watch.c | 43 |
1 files changed, 36 insertions, 7 deletions
diff --git a/src/ppp-watch.c b/src/ppp-watch.c index 5092c812..66bb03dc 100644 --- a/src/ppp-watch.c +++ b/src/ppp-watch.c @@ -32,7 +32,7 @@ * else: * while (1): * sigsuspend() - * if SIGTERM: + * if SIGTERM or SIGINT: * kill pppd pgrp * exit * if SIGHUP: @@ -85,6 +85,7 @@ static int theSigio = 0; static int theSigchld = 0; static int theSigalrm = 0; +static int theChild; static void @@ -92,6 +93,25 @@ cleanExit(int exitCode); +static void +forward_signal(int signo) { + kill(theChild, SIGINT); +} + + + + +static void +set_signal(int signo, void (*handler)(int)) { + struct sigaction act; + + act.sa_handler = handler; + act.flags = SA_RESTART; + sigemptyset(&act.sa_mask); + sigaction(signo, &act, NULL); +} + + static void detach(int now, int parentExitCode, char *device) { @@ -115,6 +135,15 @@ detach(int now, int parentExitCode, char *device) { if (child) { /* parent process */ close (pipeArray[1]); + + /* forward likely signals to the main process; we will + * react later + */ + theChild = child + set_signal(SIGINT, forward_signal); + set_signal(SIGTERM, forward_signal); + set_signal(SIGHUP, forward_signal); + while (read (pipeArray[0], &exitCode, 1) < 0) { switch (errno) { case EINTR: continue; @@ -443,13 +472,13 @@ main(int argc, char **argv) { doPidFile(real_device); - signal(SIGTERM, signal_handler); - signal(SIGINT, signal_handler); - signal(SIGHUP, signal_handler); - signal(SIGIO, signal_handler); - signal(SIGCHLD, signal_handler); + set_signal(SIGTERM, signal_handler); + set_signal(SIGINT, signal_handler); + set_signal(SIGHUP, signal_handler); + set_signal(SIGIO, signal_handler); + set_signal(SIGCHLD, signal_handler); if (theBoot) { - signal(SIGALRM, signal_handler); + set_signal(SIGALRM, signal_handler); alarm(30); } |