diff options
author | Michael K. Johnson <johnsonm@redhat.com> | 1999-09-23 06:00:39 +0000 |
---|---|---|
committer | Michael K. Johnson <johnsonm@redhat.com> | 1999-09-23 06:00:39 +0000 |
commit | f2101f99f933cb557b9a402c7649040ae5472508 (patch) | |
tree | 2a095122a1b345360be38acf39ec4115d1eca7e7 /src | |
parent | 4959555ff45a0665429c6a71ce7b5648a83c6d09 (diff) | |
download | initscripts-f2101f99f933cb557b9a402c7649040ae5472508.tar initscripts-f2101f99f933cb557b9a402c7649040ae5472508.tar.gz initscripts-f2101f99f933cb557b9a402c7649040ae5472508.tar.bz2 initscripts-f2101f99f933cb557b9a402c7649040ae5472508.tar.xz initscripts-f2101f99f933cb557b9a402c7649040ae5472508.zip |
make ppp-watch kill leftover dialer more reliably
Diffstat (limited to 'src')
-rw-r--r-- | src/ppp-watch.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/src/ppp-watch.c b/src/ppp-watch.c index 5a0e7054..dc0454ef 100644 --- a/src/ppp-watch.c +++ b/src/ppp-watch.c @@ -211,6 +211,13 @@ fork_exec(int wait, char *path, char *arg1, char *arg2, char *arg3) if (!(child = fork())) { /* child */ + + if (!wait) { + /* make sure that pppd is in its own process group */ + setsid(); + setpgid(0, 0); + } + execl(path, path, arg1, arg2, arg3, NULL); perror(path); _exit (1); @@ -444,7 +451,10 @@ main(int argc, char **argv) { physicalDevice = pppLogicalToPhysical(&pppdPid, device); if (physicalDevice) { free(physicalDevice); physicalDevice = NULL; } kill(pppdPid, sendsig); - if (sendsig == SIGKILL) cleanExit(32); + if (sendsig == SIGKILL) { + kill(-pppdPid, sendsig); + cleanExit(32); + } } if (theSighup) { theSighup = 0; @@ -484,6 +494,16 @@ main(int argc, char **argv) { waited = wait3(&status, 0, NULL); if (waited < 0) continue; + /* now, we need to kill any children of pppd still in pppd's + * process group, in case they are hanging around. + * pppd is dead (we just waited for it) but there is no + * guarantee that its children are dead, and they will + * hold the modem if we do not get rid of them. + * We have kept the old pid/pgrp around in pppdPid. + */ + kill(-pppdPid, SIGKILL); + pppdPid = 0; + if (!WIFEXITED(status)) cleanExit(29); if (dieing) cleanExit(WEXITSTATUS(status)); |