diff options
author | Fumitoshi UKAI <ukai@debian.or.jp> | 2003-02-18 15:43:23 +0000 |
---|---|---|
committer | Fumitoshi UKAI <ukai@debian.or.jp> | 2003-02-18 15:43:23 +0000 |
commit | 8d7f5e6241178648cb4451694e1e909cb0e6931c (patch) | |
tree | 71b8855bcfce319867117e958e15969b92dde8be /etc.c | |
parent | [w3m-dev 03753] Fixed multipart.cgi (diff) | |
download | w3m-8d7f5e6241178648cb4451694e1e909cb0e6931c.tar.gz w3m-8d7f5e6241178648cb4451694e1e909cb0e6931c.zip |
[w3m-dev 03758] Re: SVR4 signal behavior
* etc.c (reset_signals): use mySignal()
(setup_child): ditto
(myExec): ditto
(mySignal): added, use sigaction if available
* fm.h (TRAP_ON): use mySignal
(TRAP_OFF): ditto
* istream.c (ISclose): ditto
* main.c (sig_chld): ditto
(main): ditto
(do_dump): ditto
(resize_hook): ditto
(resize_handler): ditto
(srchcore): ditto
(readsh): ditto
(SigAlarm): ditto
* proto.h (mySignal): added
* terms.c (error_dump): use mySignal()
(set_int): ditto
(mouse_init): ditto
From: Atsushi YOKOYAMA <yoko-a@cmh.fuchu.toshiba.co.jp>
Diffstat (limited to 'etc.c')
-rw-r--r-- | etc.c | 49 |
1 files changed, 36 insertions, 13 deletions
@@ -1,4 +1,4 @@ -/* $Id: etc.c,v 1.64 2003/02/06 17:21:43 ukai Exp $ */ +/* $Id: etc.c,v 1.65 2003/02/18 15:43:23 ukai Exp $ */ #include "fm.h" #include <pwd.h> #include "myctype.h" @@ -1335,21 +1335,21 @@ romanAlphabet(int n) static void reset_signals(void) { - signal(SIGHUP, SIG_DFL); /* terminate process */ - signal(SIGINT, SIG_DFL); /* terminate process */ - signal(SIGQUIT, SIG_DFL); /* terminate process */ - signal(SIGTERM, SIG_DFL); /* terminate process */ - signal(SIGILL, SIG_DFL); /* create core image */ - signal(SIGIOT, SIG_DFL); /* create core image */ - signal(SIGFPE, SIG_DFL); /* create core image */ + mySignal(SIGHUP, SIG_DFL); /* terminate process */ + mySignal(SIGINT, SIG_DFL); /* terminate process */ + mySignal(SIGQUIT, SIG_DFL); /* terminate process */ + mySignal(SIGTERM, SIG_DFL); /* terminate process */ + mySignal(SIGILL, SIG_DFL); /* create core image */ + mySignal(SIGIOT, SIG_DFL); /* create core image */ + mySignal(SIGFPE, SIG_DFL); /* create core image */ #ifdef SIGBUS - signal(SIGBUS, SIG_DFL); /* create core image */ + mySignal(SIGBUS, SIG_DFL); /* create core image */ #endif /* SIGBUS */ #ifdef SIGCHLD - signal(SIGCHLD, SIG_IGN); + mySignal(SIGCHLD, SIG_IGN); #endif #ifdef SIGPIPE - signal(SIGPIPE, SIG_IGN); + mySignal(SIGPIPE, SIG_IGN); #endif } @@ -1379,7 +1379,7 @@ void setup_child(int child, int i, int f) { reset_signals(); - signal(SIGINT, SIG_IGN); + mySignal(SIGINT, SIG_IGN); if (!child) SETPGRP(); close_tty(); @@ -1450,7 +1450,7 @@ open_pipe_rw(FILE ** fr, FILE ** fw) void myExec(char *command) { - signal(SIGINT, SIG_DFL); + mySignal(SIGINT, SIG_DFL); execl("/bin/sh", "sh", "-c", command, NULL); exit(127); } @@ -1973,3 +1973,26 @@ FQDN(char *host) } #endif /* USE_COOKIE */ + +void (*mySignal(int signal_number, void (*action)(int)))(int) +{ +#ifdef SA_RESTART + struct sigaction new_action, old_action; + + sigemptyset(&new_action.sa_mask); + new_action.sa_handler = action; + if (signal_number == SIGALRM) { +#ifdef SA_INTERRUPT + new_action.sa_flags = SA_INTERRUPT; +#else + new_action.sa_flags = 0; +#endif + } else { + new_action.sa_flags = SA_RESTART; + } + sigaction(signal_number, &new_action, &old_action); + return(old_action.sa_handler); +#else + return(signal(signal_number, action)); +#endif +} |