Changed signal handlers

This commit is contained in:
Michiel Broek 2003-10-13 21:36:30 +00:00
parent 15067205a8
commit 933b73246f
6 changed files with 262 additions and 244 deletions

View File

@ -24,6 +24,7 @@ v0.39.0 09-Oct-2003
Shakhaylo. This is experimental and looks compatible with Shakhaylo. This is experimental and looks compatible with
mailers that don't support this option. The compression will mailers that don't support this option. The compression will
transfer some files about twice as fast as without compression. transfer some files about twice as fast as without compression.
Changed signal handlers to better detect broken TCP links.
lang: lang:
Added language prompt 20. Added language prompt 20.

View File

@ -106,7 +106,7 @@ dietifna.o: ../config.h ../lib/libs.h ../lib/structs.h ../lib/common.h ../lib/no
emsidat.o: ../config.h ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/nodelist.h ../lib/dbnode.h emsi.h session.h lutil.h config.h emsidat.h filetime.h emsidat.o: ../config.h ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/nodelist.h ../lib/dbnode.h emsi.h session.h lutil.h config.h emsidat.h filetime.h
filelist.o: ../config.h ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/clcomm.h ../lib/common.h ../lib/nodelist.h config.h session.h filelist.h filelist.o: ../config.h ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/clcomm.h ../lib/common.h ../lib/nodelist.h config.h session.h filelist.h
openfile.o: ../config.h ../lib/libs.h ../lib/structs.h ../lib/clcomm.h ../lib/common.h ../lib/users.h ../lib/records.h config.h lutil.h openfile.h openfile.o: ../config.h ../lib/libs.h ../lib/structs.h ../lib/clcomm.h ../lib/common.h ../lib/users.h ../lib/records.h config.h lutil.h openfile.h
openport.o: ../config.h ../lib/libs.h ../lib/structs.h ../lib/common.h ../lib/clcomm.h ulock.h ttyio.h openport.h openport.o: ../config.h ../lib/libs.h ../lib/structs.h ../lib/common.h ../lib/clcomm.h ulock.h ttyio.h mbcico.h openport.h
opentcp.o: ../config.h ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/nodelist.h ../lib/dbnode.h session.h ttyio.h openport.h opentcp.h opentcp.o: ../config.h ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/nodelist.h ../lib/dbnode.h session.h ttyio.h openport.h opentcp.h
rdoptions.o: ../config.h ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/nodelist.h ../lib/dbnode.h session.h config.h rdoptions.o: ../config.h ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/nodelist.h ../lib/dbnode.h session.h config.h
yoohoo.o: ../config.h ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/clcomm.h ../lib/common.h ../lib/nodelist.h ../lib/dbnode.h ../lib/mberrors.h statetbl.h ttyio.h session.h config.h emsi.h hydra.h rdoptions.h wazoo.h dietifna.h yoohoo.h inbound.h yoohoo.o: ../config.h ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/clcomm.h ../lib/common.h ../lib/nodelist.h ../lib/dbnode.h ../lib/mberrors.h statetbl.h ttyio.h session.h config.h emsi.h hydra.h rdoptions.h wazoo.h dietifna.h yoohoo.h inbound.h

View File

@ -189,13 +189,13 @@ int main(int argc, char *argv[])
Syslog(' ', "MBCICO v%s", VERSION); Syslog(' ', "MBCICO v%s", VERSION);
/* /*
* Catch all signals we can, and handle the rest. * Catch all signals we can, and ignore the rest.
*/ */
for (i = 0; i < NSIG; i++) { for (i = 0; i < NSIG; i++) {
if ((i == SIGINT) || (i == SIGBUS) || (i == SIGFPE) || (i == SIGSEGV)) { if ((i == SIGINT) || (i == SIGBUS) || (i == SIGILL) || (i == SIGSEGV) || (i == SIGTERM) || (i == SIGKILL)) {
signal(i, (void (*))die); signal(i, (void (*))die);
} else { } else {
signal(i, SIG_DFL); signal(i, SIG_IGN);
} }
} }

View File

@ -1,11 +1,11 @@
/***************************************************************************** /*****************************************************************************
* *
* $Id$
* File ..................: mbcico/openport.c * File ..................: mbcico/openport.c
* Purpose ...............: Fidonet mailer * Purpose ...............: Fidonet mailer
* Last modification date : 07-Aug-2001
* *
***************************************************************************** *****************************************************************************
* Copyright (C) 1997-2001 * Copyright (C) 1997-2003
* *
* Michiel Broek FIDO: 2:280/2802 * Michiel Broek FIDO: 2:280/2802
* Beekmansbos 10 * Beekmansbos 10
@ -36,6 +36,7 @@
#include "../lib/clcomm.h" #include "../lib/clcomm.h"
#include "ulock.h" #include "ulock.h"
#include "ttyio.h" #include "ttyio.h"
#include "mbcico.h"
#include "openport.h" #include "openport.h"
@ -76,10 +77,8 @@ void interrupt(int sig)
int openport(char *port, int speed) int openport(char *port, int speed)
{ {
int rc, rc2; int rc, rc2, fd, outflags;
char *errtty=NULL; char *errtty=NULL;
int fd;
int outflags;
Syslog('t', "Try opening port \"%s\" at %d",MBSE_SS(port),speed); Syslog('t', "Try opening port \"%s\" at %d",MBSE_SS(port),speed);
if (openedport) if (openedport)
@ -119,13 +118,15 @@ int openport(char *port, int speed)
} }
tty_status = 0; tty_status = 0;
hanged_up = 0; hanged_up = 0;
Syslog('t', "SIGHUP => linedrop()");
signal(SIGHUP, linedrop); signal(SIGHUP, linedrop);
Syslog('t', "SIGPIPE => sigpipe()");
signal(SIGPIPE, sigpipe); signal(SIGPIPE, sigpipe);
Syslog('t', "SIGINT => interrupt()");
signal(SIGINT, interrupt); signal(SIGINT, interrupt);
rc = 0; rc = 0;
rc2 = 0; rc2 = 0;
Syslog('T', "Try open %s", MBSE_SS(openedport));
if ((fd = open(openedport,O_RDONLY|O_NONBLOCK)) != 0) { if ((fd = open(openedport,O_RDONLY|O_NONBLOCK)) != 0) {
rc = 1; rc = 1;
Syslog('+', "$Cannot open \"%s\" as stdin",MBSE_SS(openedport)); Syslog('+', "$Cannot open \"%s\" as stdin",MBSE_SS(openedport));
@ -152,8 +153,6 @@ int openport(char *port, int speed)
need_detach=0; need_detach=0;
} }
Syslog('T', "after open rc=%d",rc);
if (rc) if (rc)
Syslog('+', "cannot switch i/o to port \"%s\"",MBSE_SS(openedport)); Syslog('+', "cannot switch i/o to port \"%s\"",MBSE_SS(openedport));
else { else {
@ -176,7 +175,7 @@ int openport(char *port, int speed)
WriteError("$SETFL error"); WriteError("$SETFL error");
} }
} }
Syslog('T', "File flags: stdin: 0x%04x, stdout: 0x%04x", f_flags,outflags); Syslog('t', "File flags: stdin: 0x%04x, stdout: 0x%04x", f_flags,outflags);
} }
if (rc) if (rc)
@ -195,10 +194,14 @@ int openport(char *port, int speed)
void localport(void) void localport(void)
{ {
Syslog('t', "Setting port \"%s\" local",MBSE_SS(openedport)); Syslog('t', "Setting port \"%s\" local",MBSE_SS(openedport));
signal(SIGHUP,SIG_IGN); Syslog('t', "SIGHUP => SIG_IGN");
signal(SIGPIPE,SIG_IGN); signal(SIGHUP, SIG_IGN);
Syslog('t', "SIGPIPE => SIG_IGN");
signal(SIGPIPE, SIG_IGN);
if (isatty(0)) if (isatty(0))
tty_local(); tty_local();
return; return;
} }
@ -209,6 +212,7 @@ void nolocalport(void)
Syslog('t', "Setting port \"%s\" non-local",MBSE_SS(openedport)); Syslog('t', "Setting port \"%s\" non-local",MBSE_SS(openedport));
if (isatty(0)) if (isatty(0))
tty_nolocal(); tty_nolocal();
return; return;
} }
@ -217,8 +221,10 @@ void nolocalport(void)
int rawport(void) int rawport(void)
{ {
tty_status = 0; tty_status = 0;
signal(SIGHUP,linedrop); Syslog('t', "SIGHUP => linedrop()");
signal(SIGPIPE,sigpipe); signal(SIGHUP, linedrop);
Syslog('t', "SIGPIPE => sigpipe()");
signal(SIGPIPE, sigpipe);
if (isatty(0)) if (isatty(0))
return tty_raw(0); return tty_raw(0);
@ -230,8 +236,10 @@ int rawport(void)
int cookedport(void) int cookedport(void)
{ {
signal(SIGHUP,SIG_IGN); Syslog('t', "SIGHUP => SIG_IGN");
signal(SIGPIPE,SIG_IGN); signal(SIGHUP, SIG_IGN);
Syslog('t', "SIGHUP => SIG_IGN");
signal(SIGPIPE, SIG_IGN);
if (isatty(0)) if (isatty(0))
return tty_cooked(); return tty_cooked();
else else
@ -264,7 +272,8 @@ void closeport(void)
void sendbrk(void) void sendbrk(void)
{ {
Syslog('t', "Send break"); Syslog('t', "Send break");
if (isatty(0))
if (isatty(0)) {
#if (defined(TIOCSBRK)) #if (defined(TIOCSBRK))
Syslog('t', "TIOCSBRK"); Syslog('t', "TIOCSBRK");
ioctl(0, TIOCSBRK, 0L); ioctl(0, TIOCSBRK, 0L);
@ -274,6 +283,7 @@ void sendbrk(void)
#else /* any ideas about BSD? */ #else /* any ideas about BSD? */
; ;
#endif #endif
}
} }
@ -500,8 +510,7 @@ speed_t transpeed(int speed)
{ {
speed_t tspeed; speed_t tspeed;
switch (speed) switch (speed) {
{
case 0: tspeed=0; break; case 0: tspeed=0; break;
#if defined(B50) #if defined(B50)
case 50: tspeed=B50; break; case 50: tspeed=B50; break;

View File

@ -1,9 +1,11 @@
#ifndef _OPENPORT_H #ifndef _OPENPORT_H
#define _OPENPORT_H #define _OPENPORT_H
/* $Id$ */
void linedrop(int); void linedrop(int);
void interrupt(int); void interrupt(int);
void sigpipe(int);
#ifdef TIOCWONLINE #ifdef TIOCWONLINE
void alarmsig(int); void alarmsig(int);
#endif #endif

View File

@ -149,7 +149,10 @@ int opentcp(char *name)
return -1; return -1;
} }
signal(SIGPIPE,linedrop); Syslog('d', "SIGPIPE => sigpipe()");
signal(SIGPIPE, sigpipe);
Syslog('d', "SIGHUP => linedrop()");
signal(SIGHUP, linedrop);
fflush(stdin); fflush(stdin);
fflush(stdout); fflush(stdout);
setbuf(stdin,NULL); setbuf(stdin,NULL);
@ -202,7 +205,10 @@ void closetcp(void)
tel_leave_binary(3); tel_leave_binary(3);
shutdown(fd, 2); shutdown(fd, 2);
signal(SIGPIPE,SIG_DFL); Syslog('d', "SIGHUP => SIG_IGN");
signal(SIGHUP, SIG_IGN);
Syslog('d', "SIGPIPE => SIG_IGN");
signal(SIGPIPE, SIG_IGN);
if (carrier) { if (carrier) {
c_end = time(NULL); c_end = time(NULL);