rc-list - mailing list for the rc(1) shell
 help / color / mirror / Atom feed
* Re: signal blocking?
@ 1992-04-08 13:18 Chet Ramey
  1992-04-08 18:33 ` schwartz
  0 siblings, 1 reply; 9+ messages in thread
From: Chet Ramey @ 1992-04-08 13:18 UTC (permalink / raw)
  To: schwartz; +Cc: arnold, rc, chet

> | Get this.  The function works ok with the version of rc linked with
> | the readline library, and bombs on the version without it.  Sigh.
> 
> That's because readline ignores the return code from read(), while
> Byron carefully checks it.

Oh, please, give me a break.  Why not check these things out before
shooting from the hip?

From rl_getc:

      result = read (fileno (stream), &c, sizeof (unsigned char));

      if (result == sizeof (unsigned char))
        return (c);

      /* If zero characters are returned, then the file that we are
         reading from is empty!  Return EOF in that case. */
      if (result == 0)
        return (EOF);

		... and so on ...

Chet

--
``The use of history as therapy means the corruption of history as history.''
	-- Arthur Schlesinger

Chet Ramey, Case Western Reserve University	Internet: chet@po.CWRU.Edu


^ permalink raw reply	[flat|nested] 9+ messages in thread
* Re: signal blocking?
@ 1992-04-08 15:49 Byron Rakitzis
  0 siblings, 0 replies; 9+ messages in thread
From: Byron Rakitzis @ 1992-04-08 15:49 UTC (permalink / raw)
  To: rc

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;
  }
  
  /*


^ permalink raw reply	[flat|nested] 9+ messages in thread
* Re: signal blocking?
@ 1992-04-07 22:25 Arnold Robbins
  1992-04-07 23:24 ` schwartz
  0 siblings, 1 reply; 9+ messages in thread
From: Arnold Robbins @ 1992-04-07 22:25 UTC (permalink / raw)
  To: schwartz; +Cc: rc

Get this.  The function works ok with the version of rc linked with
the readline library, and bombs on the version without it.  Sigh.

Arnold


^ permalink raw reply	[flat|nested] 9+ messages in thread
* Re: signal blocking?
@ 1992-04-07 22:22 Arnold Robbins
  0 siblings, 0 replies; 9+ messages in thread
From: Arnold Robbins @ 1992-04-07 22:22 UTC (permalink / raw)
  To: schwartz; +Cc: rc

> To: arnold@cc.gatech.edu (Arnold Robbins)
> Cc: rc@archone.tamu.edu
> Subject: Re: signal blocking? 
> Date: 	Tue, 7 Apr 1992 18:12:20 -0400
> From: schwartz@groucho.cs.psu.edu
> 
> | So I need to temporarily block
> | SIGWINCH (ignore it basically) inside my SIGWINCH handler.
> 
> fn sigfoo {}  should set SIGFOO to SIG_IGN.  Will that do it for you?

No, since I need to do it inside the handler for SIGFOO...

> I notice that if I write
> 
> ; fn sigwinch { stty }
> 
> and then resize my xterm, rc exits fdgchar with ``read: No such file or
> directory''.
> 
> (This is on a Sun4 under SunOS 4.1.1.)

This is the result I was getting, although I didn't know where in rc
it was coming from; that's why I added the sleep.

Arnold


^ permalink raw reply	[flat|nested] 9+ messages in thread
[parent not found: <91Dec18.230318cst.18887@archone.tamu.edu>]

end of thread, other threads:[~1992-04-08 18:34 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1992-04-08 13:18 signal blocking? Chet Ramey
1992-04-08 18:33 ` schwartz
  -- strict thread matches above, loose matches on Subject: below --
1992-04-08 15:49 Byron Rakitzis
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

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).