rc-list - mailing list for the rc(1) shell
 help / color / mirror / Atom feed
From: Tom Culliton <culliton@clark.net>
To: smarry@pantransit.smar.reptiles.org
Cc: broman@nosc.mil, culliton@clark.net,
	debian-devel@lists.debian.org, rc@hawkwind.utcs.toronto.edu,
	culliton@clark.net
Subject: Re: "rc" shell maintainer?
Date: Thu, 5 Feb 1998 10:25:42 -0500	[thread overview]
Message-ID: <199802051525.KAA02997@shell.clark.net> (raw)
In-Reply-To: Your message of "05 Feb 1998 05:01:30 GMT." <19980205050130.12464.qmail@pantransit.smar.reptiles.org>

On 05 Feb 1998 05:01:30 GMT, smarry@pantransit.smar.reptiles.org wrote:
> Hello, this is Marc Moorcroft.  I joined the list shortly after
> running into two problems with rc-1.5b2 under Linux.
> 
> One definite bug (reported to Tim Goodwin) will cause rc to spin calling
> wait(2) if you do:
> 
> {ls & wait} | cat
> 
> There is another problem with signal handling that is a little more
> complicated.  When I upgraded to the 2.0.33 kernel, rc began hanging
> occasionally when I interrupted programs, and when I finally got irritated
> enough to check it thoroughly, I found that it failed trip.rc at:
> 
> kill -2 $pid
> 
> The relevant code is rc_wait() in wait.c:
> 
> static pid_t rc_wait(int *stat) {
> 	int r;
> 	interrupt_happened = FALSE;
> 	if (!setjmp(slowbuf.j)) {
> 		slow = TRUE;
> 		if (!interrupt_happened)
> 			r = wait(stat);
> 		else
> 			r = -1;
> 	} else
> 		r = -1;
> 	slow = FALSE;
> 	return r;
> }
> 
> It appears that some of the time, Linux will return from the wait(2)
> for the 'kill' process before the signal gets delivered.  On Linux
> installations where signal(2) has the System V behaviour (system calls
> are interrupted for signals that are caught via signal(2)) rc longjmps
> out of the signal handler (a rather alarming practice in itself) to the
> top of the enclosing code in rc_wait().  The sequence of events appears
> to be:
> 
> 	The signal is sent,
> 
> 	the process exits,
> 
> 	wait(2) returns successfully, and
> 
> 	before the longjmp gadgetry can be turned off (slow = FALSE),
> 	the signal handler IMMEDIATELY runs,
> 
> 	longjmps back to the top of the setjmp block,
> 
> and the PID that wait(2) returned is lost.  rc loops forever calling
> wait(2) with no children, waiting for the lost PID to turn up.

Shouldn't the "interrupt_happened" flag prevent this?

> I've talked to others who have had different problems on other Linux
> installations, where caught signals do not interrupt system calls, as
> in BSD.  This appears to be due to a difference of opinion between the
> libc and glibc people about how signals should behave, but I haven't
> investigated it myself.

It sounds like you're running RedHat 5.0 or some other distribution
which uses glibc.  I haven't taken that step, partly on the "beware of
version X.0 of anything" and partly because I'm waiting until I get a
new machine.  Sounds like this is another good reason, having heard
lots of complaints of problems with glibc.

The ultimate solution maybe to move to the world of sigaction/sigblock
where those calls are available.  The signal handling in rc is one of
the hairyest aspects of the code due to portability issues and race
conditions.  Byron spent a lot of time (the change logs are full of
it) fixing race conditions and signal handling before he passed on the
torch.  (BTW - Anyone heard from him recently?)

Tom


  reply	other threads:[~1998-02-05 21:59 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-02-05  5:01 smarry
1998-02-05 15:25 ` Tom Culliton [this message]
1998-02-06 17:45 ` Tim Goodwin
  -- strict thread matches above, loose matches on Subject: below --
1998-02-05 19:59 smarry
1998-02-04 21:23 Vincent Broman
1998-02-05  1:17 ` Tom Culliton
1998-02-05 11:46 ` Tim Goodwin
1998-02-05 21:48   ` Vincent Broman
1998-02-06 18:00     ` Tim Goodwin
1998-02-06 22:54       ` Vincent Broman
1998-02-09 20:31       ` Vincent Broman
1998-02-09 23:45       ` Vincent Broman
1998-02-10 23:26         ` Tom Culliton
1998-02-11 10:45           ` Tim Goodwin
1998-02-11 22:23             ` Tom Culliton
1998-02-12 10:23               ` Tim Goodwin
1998-02-11 21:55           ` Vincent Broman

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=199802051525.KAA02997@shell.clark.net \
    --to=culliton@clark.net \
    --cc=broman@nosc.mil \
    --cc=debian-devel@lists.debian.org \
    --cc=rc@hawkwind.utcs.toronto.edu \
    --cc=smarry@pantransit.smar.reptiles.org \
    /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).