Changed signal handlers
This commit is contained in:
parent
15067205a8
commit
933b73246f
@ -24,6 +24,7 @@ v0.39.0 09-Oct-2003
|
||||
Shakhaylo. This is experimental and looks compatible with
|
||||
mailers that don't support this option. The compression will
|
||||
transfer some files about twice as fast as without compression.
|
||||
Changed signal handlers to better detect broken TCP links.
|
||||
|
||||
lang:
|
||||
Added language prompt 20.
|
||||
|
@ -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
|
||||
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
|
||||
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
|
||||
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
|
||||
|
@ -189,13 +189,13 @@ int main(int argc, char *argv[])
|
||||
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++) {
|
||||
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);
|
||||
} else {
|
||||
signal(i, SIG_DFL);
|
||||
signal(i, SIG_IGN);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,11 +1,11 @@
|
||||
/*****************************************************************************
|
||||
*
|
||||
* $Id$
|
||||
* File ..................: mbcico/openport.c
|
||||
* Purpose ...............: Fidonet mailer
|
||||
* Last modification date : 07-Aug-2001
|
||||
*
|
||||
*****************************************************************************
|
||||
* Copyright (C) 1997-2001
|
||||
* Copyright (C) 1997-2003
|
||||
*
|
||||
* Michiel Broek FIDO: 2:280/2802
|
||||
* Beekmansbos 10
|
||||
@ -36,6 +36,7 @@
|
||||
#include "../lib/clcomm.h"
|
||||
#include "ulock.h"
|
||||
#include "ttyio.h"
|
||||
#include "mbcico.h"
|
||||
#include "openport.h"
|
||||
|
||||
|
||||
@ -76,10 +77,8 @@ void interrupt(int sig)
|
||||
|
||||
int openport(char *port, int speed)
|
||||
{
|
||||
int rc, rc2;
|
||||
int rc, rc2, fd, outflags;
|
||||
char *errtty=NULL;
|
||||
int fd;
|
||||
int outflags;
|
||||
|
||||
Syslog('t', "Try opening port \"%s\" at %d",MBSE_SS(port),speed);
|
||||
if (openedport)
|
||||
@ -119,13 +118,15 @@ int openport(char *port, int speed)
|
||||
}
|
||||
tty_status = 0;
|
||||
hanged_up = 0;
|
||||
Syslog('t', "SIGHUP => linedrop()");
|
||||
signal(SIGHUP, linedrop);
|
||||
Syslog('t', "SIGPIPE => sigpipe()");
|
||||
signal(SIGPIPE, sigpipe);
|
||||
Syslog('t', "SIGINT => interrupt()");
|
||||
signal(SIGINT, interrupt);
|
||||
rc = 0;
|
||||
rc2 = 0;
|
||||
|
||||
Syslog('T', "Try open %s", MBSE_SS(openedport));
|
||||
if ((fd = open(openedport,O_RDONLY|O_NONBLOCK)) != 0) {
|
||||
rc = 1;
|
||||
Syslog('+', "$Cannot open \"%s\" as stdin",MBSE_SS(openedport));
|
||||
@ -152,8 +153,6 @@ int openport(char *port, int speed)
|
||||
need_detach=0;
|
||||
}
|
||||
|
||||
Syslog('T', "after open rc=%d",rc);
|
||||
|
||||
if (rc)
|
||||
Syslog('+', "cannot switch i/o to port \"%s\"",MBSE_SS(openedport));
|
||||
else {
|
||||
@ -176,7 +175,7 @@ int openport(char *port, int speed)
|
||||
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)
|
||||
@ -195,10 +194,14 @@ int openport(char *port, int speed)
|
||||
void localport(void)
|
||||
{
|
||||
Syslog('t', "Setting port \"%s\" local",MBSE_SS(openedport));
|
||||
Syslog('t', "SIGHUP => SIG_IGN");
|
||||
signal(SIGHUP, SIG_IGN);
|
||||
Syslog('t', "SIGPIPE => SIG_IGN");
|
||||
signal(SIGPIPE, SIG_IGN);
|
||||
|
||||
if (isatty(0))
|
||||
tty_local();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@ -209,6 +212,7 @@ void nolocalport(void)
|
||||
Syslog('t', "Setting port \"%s\" non-local",MBSE_SS(openedport));
|
||||
if (isatty(0))
|
||||
tty_nolocal();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@ -217,7 +221,9 @@ void nolocalport(void)
|
||||
int rawport(void)
|
||||
{
|
||||
tty_status = 0;
|
||||
Syslog('t', "SIGHUP => linedrop()");
|
||||
signal(SIGHUP, linedrop);
|
||||
Syslog('t', "SIGPIPE => sigpipe()");
|
||||
signal(SIGPIPE, sigpipe);
|
||||
|
||||
if (isatty(0))
|
||||
@ -230,7 +236,9 @@ int rawport(void)
|
||||
|
||||
int cookedport(void)
|
||||
{
|
||||
Syslog('t', "SIGHUP => SIG_IGN");
|
||||
signal(SIGHUP, SIG_IGN);
|
||||
Syslog('t', "SIGHUP => SIG_IGN");
|
||||
signal(SIGPIPE, SIG_IGN);
|
||||
if (isatty(0))
|
||||
return tty_cooked();
|
||||
@ -264,7 +272,8 @@ void closeport(void)
|
||||
void sendbrk(void)
|
||||
{
|
||||
Syslog('t', "Send break");
|
||||
if (isatty(0))
|
||||
|
||||
if (isatty(0)) {
|
||||
#if (defined(TIOCSBRK))
|
||||
Syslog('t', "TIOCSBRK");
|
||||
ioctl(0, TIOCSBRK, 0L);
|
||||
@ -275,6 +284,7 @@ void sendbrk(void)
|
||||
;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -500,8 +510,7 @@ speed_t transpeed(int speed)
|
||||
{
|
||||
speed_t tspeed;
|
||||
|
||||
switch (speed)
|
||||
{
|
||||
switch (speed) {
|
||||
case 0: tspeed=0; break;
|
||||
#if defined(B50)
|
||||
case 50: tspeed=B50; break;
|
||||
|
@ -1,9 +1,11 @@
|
||||
#ifndef _OPENPORT_H
|
||||
#define _OPENPORT_H
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
void linedrop(int);
|
||||
void interrupt(int);
|
||||
void sigpipe(int);
|
||||
#ifdef TIOCWONLINE
|
||||
void alarmsig(int);
|
||||
#endif
|
||||
|
@ -149,7 +149,10 @@ int opentcp(char *name)
|
||||
return -1;
|
||||
}
|
||||
|
||||
signal(SIGPIPE,linedrop);
|
||||
Syslog('d', "SIGPIPE => sigpipe()");
|
||||
signal(SIGPIPE, sigpipe);
|
||||
Syslog('d', "SIGHUP => linedrop()");
|
||||
signal(SIGHUP, linedrop);
|
||||
fflush(stdin);
|
||||
fflush(stdout);
|
||||
setbuf(stdin,NULL);
|
||||
@ -202,7 +205,10 @@ void closetcp(void)
|
||||
tel_leave_binary(3);
|
||||
|
||||
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) {
|
||||
c_end = time(NULL);
|
||||
|
Reference in New Issue
Block a user