From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <14ec7b180701291558s18d500f0m56977475aa9c80d4@mail.gmail.com> Date: Mon, 29 Jan 2007 16:58:03 -0700 From: "andrey mirtchovski" To: "Fans of the OS Plan 9 from Bell Labs" <9fans@cse.psu.edu> Subject: Re: [9fans] APE exit() In-Reply-To: <93d3f4d8c7ad444db9626af772682441@proxima.alt.za> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <93d3f4d8c7ad444db9626af772682441@proxima.alt.za> Topicbox-Message-UUID: 0a358b5a-ead2-11e9-9d60-3106f5b1d025 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);