summaryrefslogtreecommitdiffstats
path: root/usr.sbin/ppp/main.c
diff options
context:
space:
mode:
authorbrian <brian@FreeBSD.org>1997-02-19 01:14:41 +0000
committerbrian <brian@FreeBSD.org>1997-02-19 01:14:41 +0000
commit43a90c7d71583db5ceb070df332fab67e4414c6a (patch)
tree8161cb2acbf7411d686ea3f206c18cec51516bac /usr.sbin/ppp/main.c
parent87dca7091fa198d5f1e715636074dafb9e3ce7a9 (diff)
downloadFreeBSD-src-43a90c7d71583db5ceb070df332fab67e4414c6a.zip
FreeBSD-src-43a90c7d71583db5ceb070df332fab67e4414c6a.tar.gz
Tidy up signal handling.
All signal() calls have been changed to pending_signal() calls. pending_signal() is defined in the new sig.c file. It remembers the handler and traps the signal with a function that will remember the signal. main.c now calls handle_signals() to actually call the required handlers (if the above handler was called). If this doesn't close PR2662 (was PR2347), I'll cry. Joerg, I think this should go into 2.2, but I havn't done anything about it because I'm bound to botch it with the new sig.[ch] files. I've just "cvs add"'d sig.[ch] so far.... can you update to 2.2 and tell me what you did ? Thanks.
Diffstat (limited to 'usr.sbin/ppp/main.c')
-rw-r--r--usr.sbin/ppp/main.c58
1 files changed, 18 insertions, 40 deletions
diff --git a/usr.sbin/ppp/main.c b/usr.sbin/ppp/main.c
index 5743be0..08354e4 100644
--- a/usr.sbin/ppp/main.c
+++ b/usr.sbin/ppp/main.c
@@ -28,7 +28,7 @@
#include <paths.h>
#include <sys/time.h>
#include <termios.h>
-#include <signal.h>
+#include "sig.h"
#include <sys/wait.h>
#include <errno.h>
#include <netdb.h>
@@ -211,8 +211,8 @@ int signo;
static void
TerminalCont()
{
- (void)signal(SIGCONT, SIG_DFL);
- (void)signal(SIGTSTP, TerminalStop);
+ pending_signal(SIGCONT, SIG_DFL);
+ pending_signal(SIGTSTP, TerminalStop);
TtyCommandMode(getpgrp() == tcgetpgrp(0));
}
@@ -220,9 +220,9 @@ static void
TerminalStop(signo)
int signo;
{
- (void)signal(SIGCONT, TerminalCont);
+ pending_signal(SIGCONT, TerminalCont);
TtyOldMode();
- signal(SIGTSTP, SIG_DFL);
+ pending_signal(SIGTSTP, SIG_DFL);
kill(getpid(), signo);
}
@@ -346,29 +346,29 @@ char **argv;
tcgetattr(0, &oldtio); /* Save original tty mode */
- signal(SIGHUP, Hangup);
- signal(SIGTERM, CloseSession);
- signal(SIGINT, CloseSession);
- signal(SIGQUIT, CloseSession);
+ pending_signal(SIGHUP, Hangup);
+ pending_signal(SIGTERM, CloseSession);
+ pending_signal(SIGINT, CloseSession);
+ pending_signal(SIGQUIT, CloseSession);
#ifdef SIGSEGV
- signal(SIGSEGV, Hangup);
+ pending_signal(SIGSEGV, Hangup);
#endif
#ifdef SIGPIPE
- signal(SIGPIPE, Hangup);
+ pending_signal(SIGPIPE, Hangup);
#endif
#ifdef SIGALRM
- signal(SIGALRM, SIG_IGN);
+ pending_signal(SIGALRM, SIG_IGN);
#endif
if(mode & MODE_INTER)
{
#ifdef SIGTSTP
- signal(SIGTSTP, TerminalStop);
+ pending_signal(SIGTSTP, TerminalStop);
#endif
#ifdef SIGTTIN
- signal(SIGTTIN, TerminalStop);
+ pending_signal(SIGTTIN, TerminalStop);
#endif
#ifdef SIGTTOU
- signal(SIGTTOU, SIG_IGN);
+ pending_signal(SIGTTOU, SIG_IGN);
#endif
}
@@ -791,16 +791,7 @@ DoLoop()
usleep(TICKUNIT);
TimerService();
#else
- if( TimerServiceRequest > 0 ) {
-#ifdef DEBUG
- logprintf( "Invoking TimerService before select()\n" );
-#endif
- /* Maybe a bit cautious.... */
- TimerServiceRequest = -1;
- TimerService();
- TimerServiceRequest = 0;
- continue;
- }
+ handle_signals();
#endif
/* If there are aren't many packets queued, look for some more. */
@@ -834,23 +825,10 @@ DoLoop()
continue;
}
- if( TimerServiceRequest > 0 ) {
- /* we want to service any SIGALRMs even if we got it before calling
- select. */
- int rem_errno = errno;
-#ifdef DEBUG
- logprintf( "Invoking TimerService\n" );
-#endif
- /* Maybe a bit cautious.... */
- TimerServiceRequest = -1;
- TimerService();
- TimerServiceRequest = 0;
- errno = rem_errno;
- }
-
if ( i < 0 ) {
if ( errno == EINTR ) {
- continue; /* Got a signal - should have been dealt with */
+ handle_signals();
+ continue;
}
perror("select");
break;
OpenPOWER on IntegriCloud