From 14db48511e371a04187d3ddf6998334966d1ea2c Mon Sep 17 00:00:00 2001 From: Michiel Broek Date: Mon, 6 Dec 2004 21:33:30 +0000 Subject: [PATCH] Fixed NetBSD hangup and character reading --- mbsebbs/bye.c | 24 +++++++++++++++--------- mbsebbs/input.c | 6 +++++- mbsebbs/newuser.c | 1 + 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/mbsebbs/bye.c b/mbsebbs/bye.c index 60377bc9..a10f50f3 100644 --- a/mbsebbs/bye.c +++ b/mbsebbs/bye.c @@ -121,8 +121,8 @@ void Good_Bye(int onsig) cookedport(); } Syslog('b', "Will hangup"); + signal(SIGHUP, SIG_IGN); hangup(); - Syslog('b', "Done"); for (i = 0; i < NSIG; i++) { if ((i == SIGHUP) || (i == SIGPIPE) || (i == SIGBUS) || (i == SIGILL) || (i == SIGSEGV) || (i == SIGTERM)) @@ -170,19 +170,25 @@ void Quick_Bye(int onsig) sprintf(temp, "%s/tmp/mbsebbs%d", getenv("MBSE_ROOT"), getpid()); unlink(temp); free(temp); + colour(LIGHTGRAY, BLACK); + sleep(3); + + if ((onsig != SIGALRM) && (onsig != MBERR_TIMEOUT) && (hanged_up == 0)) { + cookedport(); + } + + /* + * Ignore SIGHUP during hangup + */ + signal(SIGHUP, SIG_IGN); + hangup(); /* * Prevent that we call die() if something goes wrong next */ for (i = 0; i < NSIG; i++) - if ((i == SIGHUP) || (i == SIGPIPE) || (i == SIGBUS) || (i == SIGILL) || (i == SIGSEGV) || (i == SIGTERM)) - signal(i, SIG_DFL); - - colour(LIGHTGRAY, BLACK); - sleep(3); - - cookedport(); - hangup(); + if ((i == SIGHUP) || (i == SIGPIPE) || (i == SIGBUS) || (i == SIGILL) || (i == SIGSEGV) || (i == SIGTERM)) + signal(i, SIG_DFL); free(pTTY); if (StartTime) diff --git a/mbsebbs/input.c b/mbsebbs/input.c index 20ef80f9..411cb3db 100644 --- a/mbsebbs/input.c +++ b/mbsebbs/input.c @@ -53,7 +53,11 @@ int Waitchar(unsigned char *ch, int wtime) // Syslog('t', "Waitchar(): after GETCHAR() tty_status = %d, rc = %d", tty_status, rc); if (tty_status == STAT_SUCCESS) { // Syslog('t', "Waitchar(): return %d", rc); +#ifdef __NetBSD__ + *ch = (unsigned char)rc; +#else memcpy(ch, &rc, sizeof(unsigned char)); +#endif return 1; } if (tty_status != STAT_TIMEOUT) { @@ -62,7 +66,7 @@ int Waitchar(unsigned char *ch, int wtime) } msleep(10); } - // Syslog('t', "Waitchar() timeout returns %d", rc); +// Syslog('t', "Waitchar() timeout returns %d", rc); return rc; } diff --git a/mbsebbs/newuser.c b/mbsebbs/newuser.c index 2fb84438..eda21604 100644 --- a/mbsebbs/newuser.c +++ b/mbsebbs/newuser.c @@ -625,6 +625,7 @@ void Fast_Bye(int onsig) sleep(3); cookedport(); + signal(SIGHUP, SIG_IGN); hangup(); Free_Language();