--- ppp-2.4.2/pppd/main.c 2004-01-13 06:00:34 +0200 +++ ppp-2.4.2/pppd/main.c 2006-09-26 17:09:15 +0300 @@ -177,6 +177,8 @@ int error_count; +sigset_t ignored_signals; /* to be ignored due to kill_my_pg() call */ + /* * We maintain a list of child process pids and * functions to call when they exit. @@ -217,7 +219,6 @@ static void cleanup_db __P((void)); #endif -static void handle_events __P((void)); static void print_link_stats __P((void)); extern char *ttyname __P((int)); @@ -644,7 +647,7 @@ /* * handle_events - wait for something to happen and respond to it. */ -static void +void handle_events() { struct timeval timo; @@ -767,6 +770,8 @@ * be sufficient. */ signal(SIGPIPE, SIG_IGN); + + sigemptyset(&ignored_signals); } /* @@ -1334,13 +1339,15 @@ kill_my_pg(sig) int sig; { - struct sigaction act, oldact; - - act.sa_handler = SIG_IGN; - act.sa_flags = 0; - sigaction(sig, &act, &oldact); - kill(0, sig); - sigaction(sig, &oldact, NULL); + if (sigismember(&ignored_signals, sig)) + { + sigdelset(&ignored_signals, sig); + } + else + { + sigaddset(&ignored_signals, sig); + kill(0, sig); + } } @@ -1382,6 +1389,7 @@ /* Send the signal to the [dis]connector process(es) also */ kill_my_pg(sig); notify(sigreceived, sig); + status = EXIT_USER_REQUEST; if (waiting) siglongjmp(sigjmp, 1); } --- ppp-2.4.2/pppd/pppd.h 2003-04-07 03:01:46 +0300 +++ ppp-2.4.2/pppd/pppd.h 2006-09-26 16:49:28 +0300 @@ -456,6 +456,7 @@ */ /* Procedures exported from main.c. */ +void handle_events __P((void)); /* wait for smth to happen and respond to it*/ void set_ifunit __P((int)); /* set stuff that depends on ifunit */ void detach __P((void)); /* Detach from controlling tty */ void die __P((int)); /* Cleanup and exit */ --- ppp-2.4.2/pppd/sys-linux.c 2004-01-13 06:05:20 +0200 +++ ppp-2.4.2/pppd/sys-linux.c 2006-09-26 16:04:02 +0300 @@ -995,7 +995,9 @@ if (!default_device) inittermios.c_lflag &= ~(ECHO | ECHONL); - if (tcsetattr(tty_fd, TCSAFLUSH, &inittermios) < 0) { + // Ugly hack - with TCSAFLUSH it hangs if no modem is connected + // to COM port. + if (tcsetattr(tty_fd, TCSANOW, &inittermios) < 0) { if (! ok_error (errno)) warn("tcsetattr: %m (line %d)", __LINE__); } --- ppp-2.4.2/pppd/tty.c 2004-01-13 06:17:59 +0200 +++ ppp-2.4.2/pppd/tty.c 2006-09-26 16:53:11 +0300 @@ -671,6 +671,7 @@ status = EXIT_INIT_FAILED; return -1; } + handle_events(); if (kill_link) { disconnect_tty(); return -1; @@ -681,9 +682,11 @@ if (connector && connector[0]) { if (device_script(connector, ttyfd, ttyfd, 0) < 0) { error("Connect script failed"); - status = EXIT_CONNECT_FAILED; + if (status != EXIT_USER_REQUEST) + status = EXIT_CONNECT_FAILED; return -1; } + handle_events(); if (kill_link) { disconnect_tty(); return -1; @@ -710,6 +713,7 @@ error("Failed to reopen %s: %m", devnam); status = EXIT_OPEN_FAILED; } + handle_events(); if (!persist || errno != EINTR || hungup || kill_link) return -1; }