/proc/PID/status has tgid==pgid (was: Updated: procps-ng 4.0.7-2 - pgid shown under PID)
Brian Inglis
Brian.Inglis@SystematicSW.ab.ca
Sun Oct 18 18:07:13 GMT 2026
On 2026-10-18 08:03, ASSI via Cygwin wrote:
> Brian Inglis via Cygwin writes:
>> With only personal processes, pgid == pid, so which is shown under PID?
>> With all processes -A or -e, it is obvious that pgid is shown under PID!
>
> Wrong on both counts, procps is using the tgid as documented; but see
> below.
>
>> It would be nice to have a procps(1) man page to see what is intended?
>
> That was the reason I re-released yesterday, the patch to have that
> manpage was partially removed inadvertently when re-generating it for
> 4.0.6 (which had concurrent changes from upstream in the same area).
Thank you! ;^>
>> It certainly is not compliant with POSIX ps(1p)!
>
> Of course not, you'd have to set POSIXLY_CORRECT (and create a wrapper
> to be able to call it as "ps") if you want that and then you'd probalby
> be one of a handful of persons on the whole planet who has ever done
> that.
>
> Still, procps will use the tgid as an alias for pid and Cygwin
> explicitly sets this to pgid in winsup/cygwin/fhandler/process.cc when
> creating the /proc/<pid>/status virtual file (which is where procps is
> getting its information from), so if there's a bug to be fixed, then
> there. This behaviour changed (and exposed the latent Cygwin bug
> w.r.t. tgid) with commit 9756b33 by T. Yano as this re-interpretation of
> tgid as pid only happens if Threads reads as something other than zero.
> The thread number that gets reported since then has nothing to do with
> any process/thread view from the Cygwin side (it appears to be the NT
> view instead, which almost always has extra threads for any given
> process) and certainly doesn't report the nlwp thread count that is
> expected here to be compatible with Linux. In other words, on Linux
> you'd expect to find n /proc/*/status entries with the same tgid if
> Threads is n in status, and the thread group leader has pid==tgid, while
> the other threads with the same tgid have pid!=tgid.
>
> Again it might still be acceptable if at least the tgid value was
> identical to pid when reporting the main thread (which is effectively
> all that Cygwin ever does anyway).
Ref to developers!
> I'm going to patch procps-ng to ignore the bogus Threads value in
> /proc/<pid>/status, which makes it report nlwp as 1 again as a side
> effect.
--
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-developers
mailing list