9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: "andrey mirtchovski" <mirtchovski@gmail.com>
To: "Fans of the OS Plan 9 from Bell Labs" <9fans@cse.psu.edu>
Subject: Re: [9fans] APE exit()
Date: Mon, 29 Jan 2007 16:58:03 -0700	[thread overview]
Message-ID: <14ec7b180701291558s18d500f0m56977475aa9c80d4@mail.gmail.com> (raw)
In-Reply-To: <93d3f4d8c7ad444db9626af772682441@proxima.alt.za>

I think I figured that one out.

/sys/src/ape/lib/ap/plan9/_buf.c:66 sets _killmuxsid() to be called
during exit, then forks the process nodefile. this is all fine until
exit time, when there is a race: _killmuxsid is called and tries to
kill the child via kill(-pidgroup) but the child has already exited.
kill() calls setpgid() on itself trying to become the same group as
the child, but since the child has exited setpgid() fails (there is no
such group anymore). kill() will then happily proceed and send SIGTERM
to the original note group with which it was born, which unfortunately
is the same notegroup of the shell, hence killing them both.

a proposed fix for /sys/src/ape/lib/ap/plan9/kill.c:

49,54c49,51
< 		if(setpgid(mpid, -pid) > 0) {
< 			r = note(mpid, msg, "/proc/%d/notepg");
< 			setpgid(mpid, sid);
< 		} else {
< 			r = -1;
< 		}
---
> 		setpgid(mpid, -pid);
> 		r = note(mpid, msg, "/proc/%d/notepg");
> 		setpgid(mpid, sid);


  reply	other threads:[~2007-01-29 23:58 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-01-09 17:44 lucio
2007-01-09 19:47 ` Charles Forsyth
2007-01-10  4:17   ` lucio
2007-01-29 23:58     ` andrey mirtchovski [this message]
2007-01-30  9:21       ` lucio
2007-02-02 19:33       ` lucio

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=14ec7b180701291558s18d500f0m56977475aa9c80d4@mail.gmail.com \
    --to=mirtchovski@gmail.com \
    --cc=9fans@cse.psu.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).