rc-list - mailing list for the rc(1) shell
 help / color / mirror / Atom feed
* Re:  rc and signal handlers
@ 1992-11-05 22:00 Byron Rakitzis
  0 siblings, 0 replies; 4+ messages in thread
From: Byron Rakitzis @ 1992-11-05 22:00 UTC (permalink / raw)
  To: malte, rc

signal handlers ARE function definitions. They just have the
added feature that they get run at "interrupt level". If
it's not obvious that you can't "return" from a signal
handler, then you need to think a little more carefully
about what signals are.

btw,

; fn sigint { echo hi }
; sigint
hi
;


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: rc and signal handlers
       [not found] <cks@hawkwind.utcs.toronto.edu>
@ 1992-11-06 12:03 ` malte
  0 siblings, 0 replies; 4+ messages in thread
From: malte @ 1992-11-06 12:03 UTC (permalink / raw)
  To: rc

	
	| Also, the man-page is not too clear about signals:
	|  "Only signals that are being ignored are passed on to programs run by rc"
	| The should read "signals that are being caught", I guess.
	
	 The manpage is correct as written; caught signals are not passed on to
	children, and revert to default behavior. Only ignored signals are passed
	on to children.
	
	 If one thinks about how catching signals works, it becomes obvious that
	this has to be that way.
	
		- cks

This is perfectly true! But also ugly ! This way, one has to redefine signal
handlers for each backquote substitution. On BSD and System V children
inherit signal handlers when forking and one has to change them explicitly.
Could someone explain to me why rc does it automatically ? I'd rather prefer
a simple way to reset signal handlers, something like

	fn sigreset {
		for( sig in `{ whatis -s | cut -f2 '-d ' } )
			eval fn $sig
	}

About "return"ing from a signal handler: One really doesn't want to do that.
I just mentioned it to make it clear to beginners. What bothers me most is
that rc doesn't complain about a return when defining the function and that
everything is fine when invoking the function interactively. But, when the
signal is caught, you'll get "return outside of function".

Malte



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: rc and signal handlers
  1992-11-05 20:45 malte
@ 1992-11-05 23:16 ` Chris Siebenmann
  0 siblings, 0 replies; 4+ messages in thread
From: Chris Siebenmann @ 1992-11-05 23:16 UTC (permalink / raw)
  To: rc

| Also, the man-page is not too clear about signals:
|  "Only signals that are being ignored are passed on to programs run by rc"
| The should read "signals that are being caught", I guess.

 The manpage is correct as written; caught signals are not passed on to
children, and revert to default behavior. Only ignored signals are passed
on to children.

 If one thinks about how catching signals works, it becomes obvious that
this has to be that way.

	- cks


^ permalink raw reply	[flat|nested] 4+ messages in thread

* rc and signal handlers
@ 1992-11-05 20:45 malte
  1992-11-05 23:16 ` Chris Siebenmann
  0 siblings, 1 reply; 4+ messages in thread
From: malte @ 1992-11-05 20:45 UTC (permalink / raw)
  To: rc

I just came across a situation were I want to temporarily change the
sematics of a signal handler, say during the execution of a function.

	fn doit {
		sighdlr = `` $nl { whatis -s | fgrep 'fn sigint' }
		...
		eval $sighdlr
	}

doesn't work, of course. What is needed is a kind of local signal handler,
or a way to put a signal handler definition into a variable like

	fn doit {
		whatis fn sigint var
		...
		eval $var
	}

I suggest local signal handlers and local functions.

Also, the man-page is not too clear about signals:

	"Only signals that are being ignored are passed on to programs run by rc"

The should read "signals that are being caught", I guess. Signal handler
definitions look like functions but are *not*; it should be stated that one
cannot "return" from a signal handler.

Malte


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~1992-11-06 12:03 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1992-11-05 22:00 rc and signal handlers Byron Rakitzis
     [not found] <cks@hawkwind.utcs.toronto.edu>
1992-11-06 12:03 ` malte
  -- strict thread matches above, loose matches on Subject: below --
1992-11-05 20:45 malte
1992-11-05 23:16 ` Chris Siebenmann

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