rc-list - mailing list for the rc(1) shell
 help / color / mirror / Atom feed
From: Byron Rakitzis <byron>
To: rc
Subject: Re: signal blocking?
Date: Wed, 8 Apr 1992 10:49:02 -0500	[thread overview]
Message-ID: <92Apr8.104908cdt.45326@archone.tamu.edu> (raw)

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 <signal.h>
+ #include <errno.h>
  #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;
  }
  
  /*


             reply	other threads:[~1992-04-08 15:49 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1992-04-08 15:49 Byron Rakitzis [this message]
  -- strict thread matches above, loose matches on Subject: below --
1992-04-08 13:18 Chet Ramey
1992-04-08 18:33 ` schwartz
1992-04-07 22:25 Arnold Robbins
1992-04-07 23:24 ` schwartz
1992-04-07 22:22 Arnold Robbins
     [not found] <91Dec18.230318cst.18887@archone.tamu.edu>
     [not found] ` <199201222335.28010.rc.badaj@vetsci.su.oz.au>
     [not found]   ` <92Jan28.114835cst.18891@archone.tamu.edu>
1992-04-07 21:18     ` Arnold Robbins
1992-04-07 22:12       ` schwartz
1992-04-08  1:37       ` John Mackin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=92Apr8.104908cdt.45326@archone.tamu.edu \
    --to=rc@hawkwind.utcs.toronto.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).