setpgid non-compliance with POSIX?

Jeremy Drake cygwin@jdrake.com
Mon Jun 30 19:07:25 GMT 2025


On Mon, 30 Jun 2025, Corinna Vinschen via Cygwin wrote:

> On Jun 28 12:32, Jeremy Drake via Cygwin wrote:
> > I was looking at setpgid yesterday, and it seems deficient with respect to
> > the errors required to be returned by the POSIX docs in
> > https://pubs.opengroup.org/onlinepubs/9799919799/functions/setpgid.html
> >
> > Basically, it seems that setpgid allows any arbitrary positive integer to
> > be set as pgid, rather than restricting to setting it to either the
> > process's pid or to an existing pgid in the same session (sid).
>
> Yeah, error checking in setpgid is a bit on the lacking side.  With only
> minor changes, the function is basically 25 years old :}

The POSIX docs metioned that an old BSD allowed setting arbitrary pgid

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


More information about the Cygwin mailing list