From mboxrd@z Thu Jan 1 00:00:00 1970 Received: by archone.tamu.edu id <45326>; Wed, 8 Apr 1992 10:49:08 -0500 From: Byron Rakitzis To: rc Subject: Re: signal blocking? Message-Id: <92Apr8.104908cdt.45326@archone.tamu.edu> Date: Wed, 8 Apr 1992 10:49:02 -0500 Ok, it seems this application of signal handlers is as "real" as they get. re: putting a "return" in the signal handler. This is not going to do a lot of good, since setting $status never changes the value of errno in any case. I have specifically made signal handler invocations different from function invocations (no "return" is allowed) so that one could realize that it is not a very meaningful thing to set $status in a signal handler. It seems that the fundamental limitation here is not the ability of rc to queue signals inside a signal handler, but rather the system call/errno interface. read() returns a -1 on failure---any kind of failure---and then you have to check errno to see what the error really was. When a signal handler buggers the value of errno you are really done for. Therefore my initial reaction would be to have a signal handler do a save/restore of errno, and preserve the v7 semantics of rc signal handlers; I don't really feel like changing the way signals are done in rc right now. It still seems like too much work, and the current problem can be solved with this code: ; fn sigwinch {handle} ; fn handle { fn sigwinch stty fn sigwinch {handle} } (I just tried this on a NeXT and a Sun, with a save/restore of errno in fn_handler, and a window-size-change on a terminal window) Anyway, here's a context diff for fn.c: *** fn.c.orig Sun Mar 29 10:32:36 1992 --- fn.c Wed Apr 8 10:39:35 1992 *************** *** 4,9 **** --- 4,10 ---- */ #include + #include #include "rc.h" #include "sigmsgs.h" *************** *** 84,91 **** --- 85,94 ---- static void fn_handler(int s) { List *dollarzero; Estack e; + int olderrno; if (s < 1 || s >= NUMOFSIGNALS) panic("unknown signal"); + olderrno = errno; dollarzero = nnew(List); dollarzero->w = signals[s][0]; dollarzero->n = NULL; *************** *** 94,99 **** --- 97,103 ---- walk(handlers[s], TRUE); varrm("*", TRUE); unexcept(); /* eVarstack */ + errno = olderrno; } /*