From: Paul Mackerras Date: Sat, 13 Nov 2004 12:05:48 +0000 (+0000) Subject: Make SIGHUP just take down the link now, not the bundle. X-Git-Tag: ppp-2.4.7~179 X-Git-Url: http://git.ozlabs.org/?p=ppp.git;a=commitdiff_plain;h=802908571f0d76c143db276c5988ae3f2307bd67 Make SIGHUP just take down the link now, not the bundle. Be a bit more careful about quitting when we get a SIGTERM or SIGINT. --- diff --git a/pppd/main.c b/pppd/main.c index 862a2d4..65a8877 100644 --- a/pppd/main.c +++ b/pppd/main.c @@ -66,7 +66,7 @@ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#define RCSID "$Id: main.c,v 1.147 2004/11/13 12:02:22 paulus Exp $" +#define RCSID "$Id: main.c,v 1.148 2004/11/13 12:05:48 paulus Exp $" #include #include @@ -172,6 +172,7 @@ int devfd = -1; /* fd of underlying device */ int fd_ppp = -1; /* fd for talking PPP */ int phase; /* where the link is at */ int kill_link; +int asked_to_quit; int open_ccp_flag; int listen_time; int got_sigusr2; @@ -511,13 +512,13 @@ main(argc, argv) add_fd(fd_loop); for (;;) { handle_events(); - if (kill_link && !persist) + if (asked_to_quit) break; if (get_loop_output()) break; } remove_fd(fd_loop); - if (kill_link && !persist) + if (asked_to_quit) break; /* @@ -536,9 +537,10 @@ main(argc, argv) while (phase != PHASE_DEAD) { handle_events(); get_input(); - if (kill_link) { - bundle_terminating = 1; + if (kill_link) lcp_close(0, "User request"); + if (asked_to_quit) { + bundle_terminating = 1; if (phase == PHASE_MASTER) mp_bundle_terminated(); } @@ -550,7 +552,7 @@ main(argc, argv) } } - if (!persist || (maxfail > 0 && unsuccess >= maxfail)) + if (!persist || asked_to_quit || (maxfail > 0 && unsuccess >= maxfail)) break; if (demand) @@ -624,6 +626,7 @@ handle_events() if (got_sigterm) { info("Terminating on signal %d", got_sigterm); kill_link = 1; + asked_to_quit = 1; persist = 0; status = EXIT_USER_REQUEST; got_sigterm = 0; diff --git a/pppd/tty.c b/pppd/tty.c index 991a148..85a8032 100644 --- a/pppd/tty.c +++ b/pppd/tty.c @@ -68,7 +68,7 @@ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#define RCSID "$Id: tty.c,v 1.20 2004/11/12 09:51:23 paulus Exp $" +#define RCSID "$Id: tty.c,v 1.21 2004/11/13 12:05:48 paulus Exp $" #include #include @@ -152,6 +152,8 @@ int using_pty = 0; /* we're allocating a pty as the device */ extern uid_t uid; extern int kill_link; +extern int asked_to_quit; +extern int got_sigterm; /* XXX */ extern int privopen; /* don't lock, open device as root */ @@ -547,7 +549,7 @@ int connect_tty() * in order to wait for the carrier detect signal from the modem. */ hungup = 0; - kill_link = 0; + got_sigterm = 0; connector = doing_callback? callback_script: connect_script; if (devnam[0] != 0) { for (;;) { @@ -679,7 +681,7 @@ int connect_tty() status = EXIT_INIT_FAILED; goto errret; } - if (kill_link) { + if (got_sigterm) { disconnect_tty(); goto errret; } @@ -692,7 +694,7 @@ int connect_tty() status = EXIT_CONNECT_FAILED; goto errret; } - if (kill_link) { + if (got_sigterm) { disconnect_tty(); goto errret; } @@ -718,7 +720,7 @@ int connect_tty() error("Failed to reopen %s: %m", devnam); status = EXIT_OPEN_FAILED; } - if (!persist || errno != EINTR || hungup || kill_link) + if (!persist || errno != EINTR || hungup || got_sigterm) goto errret; } close(i); @@ -757,6 +759,8 @@ int connect_tty() real_ttyfd = -1; } ttyfd = -1; + if (got_sigterm) + asked_to_quit = 1; return -1; }