This is the mail archive of the
mailing list for the Cygwin project.
Re: bash misbehavior
- From: "Pierre A. Humblet" <Pierre dot Humblet at ieee dot org>
- To: cygwin-developers at cygwin dot com
- Date: Tue, 28 Sep 2004 19:49:31 -0400
- Subject: Re: bash misbehavior
- References: <4159C919.C45AF9CC@ieee.org><firstname.lastname@example.org><20040928044625.GA25363@trixie.casa.cgf.cx><4159C919.C45AF9CC@ieee.org>
At 05:27 PM 9/28/2004 -0400, Christopher Faylor wrote:
>On Tue, Sep 28, 2004 at 04:27:05PM -0400, Pierre A. Humblet wrote:
>>> Are you sure that bash is doing the right thing?
>>Not sure, but it's doing on Cygwin what it is doing elsewhere.
>bash was expecting a certain behavior regarding pids elsewhere, too.
>That doesn't mean it's cygwin's problem.
>I could even use the argument that "it works fine on zsh".
>I'm not saying that you are not right but this argument is a no-op.
As I said, I am not sure what the explanation is.
My current hypothesis is that it shouldn't call tcsetpgrp at all!
>>So if it isn't right, there must be a Cygwin related explanation.
>>It is not pid reuse in this case.
>I'm not convinced. I know (and have known) that cygwin's behavior
>regarding pgid's is not perfect since it doesn't keep track of them
>after the process disappears but I can't convince myself from looking at
>the strace that bash is not doing something wrong there.
>Probably somehow making cygwin remember pgids until the last process
>which is using the pgid dies would rectify this problem but I don't know
>of any easy way to do that.
Here is my current thinking. When a process sets its own pgid, and it changes,
open the pgid process and save the inheritable handle on the cygheap (together
with its pgid), close the original handle (if any), and also set the pgid on
When a parent sets the pgid of the child, and it changes, open the pgid
process and dup it, non heritable, in the child's space, on the child pinfo.
When a child forks or execs, check if there is a pgid handle in the pinfo and
if there is one on the cygheap, and if the cygheap pgid matches the pinfo
pgid. Close and dup handles as needed until the right handle is inheritable
on the cygheap and there is none on the pinfo.
If the parent sets the pgid twice in a row, without the child cleaning up,
we end up with an unreferenced non-heritable handle in the child. That's
not a tragedy. There are also unlikely cases where the parent and the child
set the child's pgid to different values at the same time...
I wish this could be simplified.