zsh-workers
 help / color / mirror / code / Atom feed
From: Sven Wischnowsky <wischnow@informatik.hu-berlin.de>
To: zsh-workers@sunsite.auc.dk
Subject: Re: prob: fg not sending CONT to 'make' children
Date: Wed, 1 Sep 1999 10:08:37 +0200 (MET DST)	[thread overview]
Message-ID: <199909010808.KAA31927@beta.informatik.hu-berlin.de> (raw)
In-Reply-To: "Bart Schaefer"'s message of Tue, 31 Aug 1999 16:40:22 +0000


Bart Schaefer wrote:

> On Aug 31,  1:25pm, Sven Wischnowsky wrote:
> } Subject: Re: prob: fg not sending CONT to 'make' children
> }
> } The patch below makes the return value be -1 if at least one of the
> } kill()s failed.
> 
> Really?  It doesn't look to me as though it changes that behavior at all.
> And all those #ifdefs make it really hard to read, and testing sig != 0 is
> redundant because the whole thing is inside "if (sig == SIGCONT) ...".

(Sorry about the #ifdefs, I just copied them froom the end of the
function. I certainly should have noticed the `sig!=0' and probably
that they were not needed anyway, given the definiton in system.h.)

But: behavior not changed? Before it was:

                for (pn = jobtab[jn->other].procs; pn; pn = pn->next)
                    if (killpg(pn->pid, sig) == -1)
			kill(pn->pid, sig);
 
                for (pn = jn->procs; pn->next; pn = pn->next)
                    err = kill(pn->pid, sig);

		if (!jobtab[jn->other].procs && pn)
		    err = kill(pn->pid, sig);

                return err;

I changed it to (without the #ifdefs):

                for (pn = jobtab[jn->other].procs; pn; pn = pn->next)
                    if (killpg(pn->pid, sig) == -1)
			if (kill(pn->pid, sig) == -1 && errno != ESRCH)
			    err = -1;
 
                for (pn = jn->procs; pn->next; pn = pn->next)
                    if (kill(pn->pid, sig) == -1 && errno != ESRCH)
			err = -1;

		if (!jobtab[jn->other].procs && pn)
		    if (kill(pn->pid, sig) == -1 && errno != ESRCH)
			err = -1;

                return err;

So, err is only set to -1 if (and always if) a kill fails with an
intersting error and if another kill() later succeeds it will not be
reset to zero -- that's certainly different from before, isn't it?
(And how does your change to `|= -1' change the behavior?)

> } NOTE: while playing with this I found a bug when I did `ls|sleep 800'
> } where the `ls' finished before the `sleep' process was set up -- the
> } `sleep' put itself in its own little process group and one couldn't fg 
> } the whole thing. I tried several ways to fix this now and the hunks in 
> } `exec.c' and `utils.c' are the only ones which made this work
> 
> That's very odd.  I didn't think the PID passed to killpg() should change
> if you still want to signal the whole group, even if the group leader had
> exited.  I wonder what happens if there are more than two processes in
> the group when the leader exits?  Do all the leader's children become
> their own little leaders?

(Damn. After thinking again: there is a problem with `a | b | c' if `b' 
is started when `a' still lives and `c' is started when `a' is dead.
I'll have to look at it again. Sigh.)

The problem is in `entersubsh()' where we use `kill(..)' to test if a
forked process has to put itself in its own process group. I tried
to change this to `killpg(..)' and it fixed the problem with `a | b'
where `b' is a command. But it also made that fail if `b' is a shell
construct (or function). There is some code elsewhere which makes this 
work with the `kill(..)' for pipes ending in shell constructs -- I
have to find that place again to make it work with normal pipes, too.

Bye
 Sven


--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


             reply	other threads:[~1999-09-01  8:08 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-09-01  8:08 Sven Wischnowsky [this message]
1999-09-01 16:46 ` Bart Schaefer
  -- strict thread matches above, loose matches on Subject: below --
1999-09-01 12:11 Sven Wischnowsky
1999-08-31 11:25 Sven Wischnowsky
1999-08-31 16:40 ` Bart Schaefer
1999-08-30  8:21 Sven Wischnowsky
1999-08-30 14:43 ` Bart Schaefer
1999-08-29  7:35 Will Day
1999-08-29 18:42 ` Bart Schaefer

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=199909010808.KAA31927@beta.informatik.hu-berlin.de \
    --to=wischnow@informatik.hu-berlin.de \
    --cc=zsh-workers@sunsite.auc.dk \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

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