setpgid non-compliance with POSIX?
Brian Inglis
Brian.Inglis@SystematicSW.ab.ca
Tue Jul 1 17:17:08 GMT 2025
On 2025年06月30日 13:07, Jeremy Drake via Cygwin wrote:
> On 2025年6月30日, 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.
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.
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.
Try head /proc/self/*id & and head /proc/$$/*id as demos.
Does any of that help? ;^>
--
Take care. Thanks, Brian Inglis Calgary, Alberta, Canada
La perfection est atteinte Perfection is achieved
non pas lorsqu'il n'y a plus rien à ajouter not when there is no more to add
mais lorsqu'il n'y a plus rien à retrancher but when there is no more to cut
-- Antoine de Saint-Exupéry
More information about the Cygwin
mailing list