diff options
-rw-r--r-- | ChangeLog | 25 | ||||
-rw-r--r-- | etc.c | 49 | ||||
-rw-r--r-- | fm.h | 6 | ||||
-rw-r--r-- | istream.c | 6 | ||||
-rw-r--r-- | main.c | 40 | ||||
-rw-r--r-- | proto.h | 3 | ||||
-rw-r--r-- | terms.c | 26 |
7 files changed, 101 insertions, 54 deletions
@@ -1,3 +1,26 @@ +2003-02-19 Atsushi YOKOYAMA <yoko-a@cmh.fuchu.toshiba.co.jp> + + * [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 + 2003-02-19 Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp> * [w3m-dev 03753] Fixed multipart.cgi @@ -7174,4 +7197,4 @@ a * [w3m-dev 03276] compile error on EWS4800 * release-0-2-1 * import w3m-0.2.1 -$Id: ChangeLog,v 1.753 2003/02/18 15:26:38 ukai Exp $ +$Id: ChangeLog,v 1.754 2003/02/18 15:43:23 ukai Exp $ @@ -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 +} @@ -1,4 +1,4 @@ -/* $Id: fm.h,v 1.112 2003/02/05 16:43:57 ukai Exp $ */ +/* $Id: fm.h,v 1.113 2003/02/18 15:43:24 ukai Exp $ */ /* * w3m: WWW wo Miru utility * @@ -781,7 +781,7 @@ global char fmInitialized init(FALSE); global char QuietMessage init(FALSE); global char TrapSignal init(TRUE); #define TRAP_ON if (TrapSignal) { \ - prevtrap = signal(SIGINT, KeyAbort); \ + prevtrap = mySignal(SIGINT, KeyAbort); \ if (fmInitialized) \ term_cbreak(); \ } @@ -789,7 +789,7 @@ global char TrapSignal init(TRUE); if (fmInitialized) \ term_raw(); \ if (prevtrap) \ - signal(SIGINT, prevtrap); \ + mySignal(SIGINT, prevtrap); \ } extern unsigned char GlobalKeymap[]; @@ -1,4 +1,4 @@ -/* $Id: istream.c,v 1.20 2003/01/20 15:25:30 ukai Exp $ */ +/* $Id: istream.c,v 1.21 2003/02/18 15:43:25 ukai Exp $ */ #include "fm.h" #include "myctype.h" #include "istream.h" @@ -183,9 +183,9 @@ ISclose(InputStream stream) if (stream == NULL || stream->base.close == NULL || stream->base.type & IST_UNCLOSE) return -1; - prevtrap = signal(SIGINT, SIG_IGN); + prevtrap = mySignal(SIGINT, SIG_IGN); stream->base.close(stream->base.handle); - signal(SIGINT, prevtrap); + mySignal(SIGINT, prevtrap); return 0; } @@ -1,4 +1,4 @@ -/* $Id: main.c,v 1.210 2003/02/05 16:45:08 ukai Exp $ */ +/* $Id: main.c,v 1.211 2003/02/18 15:43:25 ukai Exp $ */ #define MAINPROGRAM #include "fm.h" #include <signal.h> @@ -317,7 +317,7 @@ sig_chld(int signo) #else wait(&p_stat); #endif - signal(SIGCHLD, sig_chld); + mySignal(SIGCHLD, sig_chld); return; } #endif @@ -730,7 +730,7 @@ main(int argc, char **argv, char **envp) if (!w3m_dump && !w3m_backend) { fmInit(); #ifdef SIGWINCH - signal(SIGWINCH, resize_hook); + mySignal(SIGWINCH, resize_hook); #else /* not SIGWINCH */ setlinescols(); setupscreen(); @@ -751,12 +751,12 @@ main(int argc, char **argv, char **envp) backend(); if (w3m_dump) - signal(SIGINT, SIG_IGN); + mySignal(SIGINT, SIG_IGN); #ifdef SIGCHLD - signal(SIGCHLD, sig_chld); + mySignal(SIGCHLD, sig_chld); #endif #ifdef SIGPIPE - signal(SIGPIPE, SigPipe); + mySignal(SIGPIPE, SigPipe); #endif orig_GC_warn_proc = GC_set_warn_proc(wrap_GC_warn_proc); @@ -1024,7 +1024,7 @@ main(int argc, char **argv, char **envp) #endif /* USE_MOUSE */ #ifdef USE_ALARM if (CurrentAlarm->sec > 0) { - signal(SIGALRM, SigAlarm); + mySignal(SIGALRM, SigAlarm); alarm(CurrentAlarm->sec); } #endif @@ -1033,7 +1033,7 @@ main(int argc, char **argv, char **envp) need_resize_screen = FALSE; resize_screen(); } - signal(SIGWINCH, resize_handler); + mySignal(SIGWINCH, resize_handler); #endif #ifdef USE_IMAGE if (activeImage && displayImage && Currentbuf->img && @@ -1045,7 +1045,7 @@ main(int argc, char **argv, char **envp) #endif c = getch(); #ifdef SIGWINCH - signal(SIGWINCH, resize_hook); + mySignal(SIGWINCH, resize_hook); #endif #ifdef USE_ALARM if (CurrentAlarm->sec > 0) { @@ -1163,9 +1163,9 @@ do_dump(Buffer *buf) { MySignalHandler(*volatile prevtrap) (SIGNAL_ARG) = NULL; - prevtrap = signal(SIGINT, intTrap); + prevtrap = mySignal(SIGINT, intTrap); if (SETJMP(IntReturn) != 0) { - signal(SIGINT, prevtrap); + mySignal(SIGINT, prevtrap); return; } if (w3m_dump & DUMP_EXTRA) @@ -1176,7 +1176,7 @@ do_dump(Buffer *buf) dump_source(buf); if (w3m_dump == DUMP_BUFFER) saveBuffer(buf, stdout, FALSE); - signal(SIGINT, prevtrap); + mySignal(SIGINT, prevtrap); } void @@ -1358,7 +1358,7 @@ static MySignalHandler resize_hook(SIGNAL_ARG) { need_resize_screen = TRUE; - signal(SIGWINCH, resize_hook); + mySignal(SIGWINCH, resize_hook); SIGNAL_RETURN; } @@ -1366,7 +1366,7 @@ static MySignalHandler resize_handler(SIGNAL_ARG) { resize_screen(); - signal(SIGWINCH, resize_handler); + mySignal(SIGWINCH, resize_handler); SIGNAL_RETURN; } @@ -1387,7 +1387,7 @@ SigPipe(SIGNAL_ARG) #ifdef USE_MIGEMO init_migemo(); #endif - signal(SIGPIPE, SigPipe); + mySignal(SIGPIPE, SigPipe); SIGNAL_RETURN; } #endif @@ -1564,7 +1564,7 @@ srchcore(char *str, int (*func) (Buffer *, char *)) if (SearchString == NULL || *SearchString == '\0') return SR_NOTFOUND; - prevtrap = signal(SIGINT, intTrap); + prevtrap = mySignal(SIGINT, intTrap); crmode(); if (SETJMP(IntReturn) == 0) { for (i = 0; i < PREC_NUM; i++) { @@ -1573,7 +1573,7 @@ srchcore(char *str, int (*func) (Buffer *, char *)) clear_mark(Currentbuf->currentLine); } } - signal(SIGINT, prevtrap); + mySignal(SIGINT, prevtrap); term_raw(); return result; } @@ -1973,10 +1973,10 @@ readsh(void) displayBuffer(Currentbuf, B_NORMAL); return; } - prevtrap = signal(SIGINT, intTrap); + prevtrap = mySignal(SIGINT, intTrap); crmode(); buf = getshell(cmd); - signal(SIGINT, prevtrap); + mySignal(SIGINT, prevtrap); term_raw(); if (buf == NULL) { disp_message("Execution failed", TRUE); @@ -5581,7 +5581,7 @@ SigAlarm(SIGNAL_ARG) if (!Currentbuf->event) CurrentAlarm = &DefaultAlarm; if (CurrentAlarm->sec > 0) { - signal(SIGALRM, SigAlarm); + mySignal(SIGALRM, SigAlarm); alarm(CurrentAlarm->sec); } } @@ -1,4 +1,4 @@ -/* $Id: proto.h,v 1.90 2003/02/06 17:21:44 ukai Exp $ */ +/* $Id: proto.h,v 1.91 2003/02/18 15:43:25 ukai Exp $ */ /* * This file was automatically generated by version 1.7 of cextract. * Manual editing not recommended. @@ -610,6 +610,7 @@ extern char *url_unquote_conv(char *url, char code); extern char *expandName(char *name); extern Str tmpfname(int type, char *ext); extern time_t mymktime(char *timestr); +extern void (*mySignal(int signal_number, void (*action)(int)))(int); #ifdef USE_COOKIE extern char *FQDN(char *host); extern Str find_cookie(ParsedURL *pu); @@ -1,4 +1,4 @@ -/* $Id: terms.c,v 1.45 2003/02/06 17:23:18 ukai Exp $ */ +/* $Id: terms.c,v 1.46 2003/02/18 15:43:26 ukai Exp $ */ /* * An original curses library for EUC-kanji by Akinori ITO, December 1989 * revised by Akinori ITO, January 1995 @@ -603,7 +603,7 @@ reset_exit(SIGNAL_ARG) MySignalHandler error_dump(SIGNAL_ARG) { - signal(SIGIOT, SIG_DFL); + mySignal(SIGIOT, SIG_DFL); reset_tty(); abort(); SIGNAL_RETURN; @@ -612,17 +612,17 @@ error_dump(SIGNAL_ARG) void set_int(void) { - signal(SIGHUP, reset_exit); - signal(SIGINT, reset_exit); - signal(SIGQUIT, reset_exit); - signal(SIGTERM, reset_exit); - signal(SIGILL, error_dump); - signal(SIGIOT, error_dump); - signal(SIGFPE, error_dump); + mySignal(SIGHUP, reset_exit); + mySignal(SIGINT, reset_exit); + mySignal(SIGQUIT, reset_exit); + mySignal(SIGTERM, reset_exit); + mySignal(SIGILL, error_dump); + mySignal(SIGIOT, error_dump); + mySignal(SIGFPE, error_dump); #ifdef SIGBUS - signal(SIGBUS, error_dump); + mySignal(SIGBUS, error_dump); #endif /* SIGBUS */ - /* signal(SIGSEGV, error_dump); */ + /* mySignal(SIGSEGV, error_dump); */ } @@ -2082,13 +2082,13 @@ mouse_init() } #endif /* defined(FBIO_MODEINFO) || * defined(CONS_MODEINFO) */ - signal(SIGUSR2, SIG_IGN); + mySignal(SIGUSR2, SIG_IGN); mi.operation = MOUSE_MODE; mi.u.mode.mode = 0; mi.u.mode.signal = SIGUSR2; sysm_handler = NULL; if (ioctl(tty, CONS_MOUSECTL, &mi) != -1) { - signal(SIGUSR2, sysmouse); + mySignal(SIGUSR2, sysmouse); mi.operation = MOUSE_SHOW; ioctl(tty, CONS_MOUSECTL, &mi); sysm_handler = sysm_process_mouse; |