microsoft / microsoft/WSL

NSpid field missing from `/proc/[pid]/status` in WSL 1

Open
#8,742 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

feature
Dominant language
C++
Stars
33.7k
Forks
1.8k
Avg merge
3d 17h
Merged PRs (30d)
116

Description

Is your feature request related to a problem? Please describe.
The fields NStgid, NSpid, NSpgid, and NSsid are missing when reading /proc/self/status. According to the documentation, these fields should have been available since Linux 4.1:

              NStgid Thread group ID (i.e., PID) in each of the PID
                     namespaces of which [pid] is a member.  The
                     leftmost entry shows the value with respect to the
                     PID namespace of the process that mounted this
                     procfs (or the root namespace if mounted by the
                     kernel), followed by the value in successively
                     nested inner namespaces.  (Since Linux 4.1.)

              NSpid  Thread ID in each of the PID namespaces of which
                     [pid] is a member.  The fields are ordered as for
                     NStgid.  (Since Linux 4.1.)

              NSpgid Process group ID in each of the PID namespaces of
                     which [pid] is a member.  The fields are ordered as
                     for NStgid.  (Since Linux 4.1.)

              NSsid  descendant namespace session ID hierarchy Session
                     ID in each of the PID namespaces of which [pid] is
                     a member.  The fields are ordered as for NStgid.
                     (Since Linux 4.1.)

While WSL 1 supports PID namespaces, there is no way to identify the PID and TID of processes in child namespaces. This breaks applications that depend on managing processes across PID namespaces, such as darling.

Describe the solution you'd like
Include NStgid, NSpid, NSpgid, and NSsid in /proc/[pid]/status, as in the documentation.

Describe alternatives you've considered
It is possible to retrieve a namespaced TID by using ptrace to inject a SYS_gettid syscall into the target thread. This approach, however, is expensive and in some cases may interfere with the target process.

Additional context
Sample run of cat /proc/self/status

Name:   cat
State:  R (running)
Tgid:   27671
Pid:    27671
PPid:   27664
TracerPid:      0
Uid:    1000    1000    1000    1000
Gid:    1000    1000    1000    1000
FDSize: 4
Groups:
VmPeak: 0 kB
VmSize: 11388 kB
VmLck:  0 kB
VmHWM:  0 kB
VmRSS:  1020 kB
VmData: 0 kB
VmStk:  0 kB
VmExe:  16 kB
VmLib:  0 kB
VmPTE:  0 kB
Threads:        1
SigQ:   0/0
SigPnd: 0000000000000000
ShdPnd: 0000000000000000
SigBlk: 0000000000000000
SigIgn: 0000000000000000
SigCgt: 0000000000000000
CapInh: 0000000000000000
CapPrm: 0000000000000000
CapEff: 0000000000000000
CapBnd: 0000001fffffffff
Cpus_allowed:   ff
Cpus_allowed_list:      0-7
Mems_allowed:   1
Mems_allowed_list:      0
voluntary_ctxt_switches:        150
nonvoluntary_ctxt_switches:     545

As you can see, the fields mentioned are missing.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the Linux proc/[pid]/status documentation and the WSL implementation of PID namespaces to locate where status fields are generated. Confirm how WSL 1 represents processes in child namespaces, then verify that NStgid, NSpid, NSpgid, and NSsid appear with the documented values in /proc/[pid]/status.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
operating-systems
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.