DMARC-Filter: OpenDMARC Filter v1.4.2 delorie.com 561IHOBr3431695
Authentication-Results: delorie.com; dmarc=pass (p=none dis=none) header.from=cygwin.com
Authentication-Results: delorie.com; spf=pass smtp.mailfrom=cygwin.com
DKIM-Filter: OpenDKIM Filter v2.11.0 delorie.com 561IHOBr3431695
Authentication-Results: delorie.com;
	dkim=pass (1024-bit key, unprotected) header.d=cygwin.com header.i=@cygwin.com header.a=rsa-sha256 header.s=default header.b=UnHUOKNx
X-Recipient: archive-cygwin@delorie.com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2E523385C6D1
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com;
	s=default; t=1751393842;
	bh=ECjat1jf9N2JbJS0LwzAf3fWD4QS+DmATsLrbK72YgE=;
	h=Date:To:Subject:In-Reply-To:References:List-Id:List-Unsubscribe:
	 List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:
	 From;
	b=UnHUOKNxpolMF3v1k7OTd0QJ3BgG9qArFEA+kYHaWsPtoXCFRNJifq4xRNzSpN3Em
	 MyMv5TSz7itkGWlXzNdxauQ87yYymINH2oaYpqGWx7ylln0/qwNe5ANmJfbLvTqOv+
	 /Hx47FbVR8fBkxqurXjYaH/3gAa2xPDMqpUToc/4=
X-Original-To: cygwin@cygwin.com
Delivered-To: cygwin@cygwin.com
DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6A0863857B9B
ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 6A0863857B9B
ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1751393811; cv=none;
 b=pIKSd+9+XJtZGo4t8igIxUxUAZ7Tb9nPra2HZTDGm9/52DdZbvCmzfj9zbzTy2N+CNkvvMs2t/CfKMIHldAcFZcJbi6CL08ACFHoyRLRm9Fz1s5L8eOmHmetY+fo8i+4nOB2b0YnwkrcRVGZ0fs8Nrd65R3JiJ6P0jOchP+FrVY=
ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key;
 t=1751393811; c=relaxed/simple;
 bh=Q6mXGAk27TDYQCQaOFCwdx8pKGhLVSZWcos3/nhseUU=;
 h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version;
 b=Ni7q5ALIxf6vjqH01geAdoc+oYTESCGhwUMXQxxF8ZC1TS6WjFAsPpD9NYPGKfh9TbSrrUjHmc/n8Zdsiu0mOUbN5WpoXj7oWWSYmn67hXm10XootZhmjnqIjwGm3zQdaUn0K9TJTt8ESWQAsgI0nRmB8rg7mamVYjFX5Bn55nQ=
ARC-Authentication-Results: i=1; server2.sourceware.org
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6A0863857B9B
Date: Tue, 1 Jul 2025 11:16:50 -0700 (PDT)
X-X-Sender: jeremyd@resin.csoft.net
To: Brian Inglis via Cygwin <cygwin@cygwin.com>
Subject: Re: setpgid non-compliance with POSIX?
In-Reply-To: <3b667ff0-7778-4b48-866f-1dd112317c84@SystematicSW.ab.ca>
Message-ID: <ef2b783c-6770-531e-26ad-b46c3180a126@jdrake.com>
References: <3391453b-7914-a319-fad8-4729610558ea@jdrake.com>
 <aGJc0nVQ-1v1DqCO@calimero.vinschen.de>
 <f5748be6-5730-ae25-20af-3ed60be5c100@jdrake.com>
 <3b667ff0-7778-4b48-866f-1dd112317c84@SystematicSW.ab.ca>
MIME-Version: 1.0
X-BeenThere: cygwin@cygwin.com
X-Mailman-Version: 2.1.30
Precedence: list
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>
List-Unsubscribe: <https://cygwin.com/mailman/options/cygwin>,
 <mailto:cygwin-request@cygwin.com?subject=unsubscribe>
List-Archive: <https://cygwin.com/pipermail/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-request@cygwin.com?subject=help>
List-Subscribe: <https://cygwin.com/mailman/listinfo/cygwin>,
 <mailto:cygwin-request@cygwin.com?subject=subscribe>
From: Jeremy Drake via Cygwin <cygwin@cygwin.com>
Reply-To: Jeremy Drake <cygwin@jdrake.com>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: cygwin-bounces~archive-cygwin=delorie.com@cygwin.com
Sender: "Cygwin" <cygwin-bounces~archive-cygwin=delorie.com@cygwin.com>

On Tue, 1 Jul 2025, Brian Inglis via Cygwin wrote:

> On 2025-06-30 13:07, Jeremy Drake via Cygwin wrote:
> > On Mon, 30 Jun 2025, Corinna Vinschen via Cygwin wrote:
> >
> >> Off the top of my head I don't know how to check the pgid already exists.
> >> Do you?
> >
> > I think it'd have to iterate all processes and check pgid and sid members
> > of pinfo until it found a match.
>
> Shouldn't need to - pgid is the pid of a process spawned by init, or pid of a
> login shell, and sid is that pgid or that of the parent process, or pgid is
> that
> of a job shell or of the parent process.

In practice, perhaps, but in theory it could get more complicated than
that.

> So each process sid also pgid is either its pid or that of its parent process:
> they are only set either to the process pid or inherited.

Not just parent, but could be inherited any level of ancestor, including
ancestors that then terminate, leaving the process adopted by init.  Also,
the restrictions given by POSIX seem to allow setting pgid to a
sibling/cousin/aunt/uncle as long as they have created a pgid (by
setting it to their pid) and are in the same sid.

> Try head /proc/self/*id & and head /proc/$$/*id as demos.
>
> Does any of that help? ;^>
>

Not really :P  I hope I don't have to write more test cases for some of
the complicated scenarios I envision being legal under the POSIX docs, I
feel like I've caused enough trouble already with the test cases I've
written trying to exercise posix_spawn :)

-- 
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple
