Project

General

Profile

Actions

Bug #14962

open

readdir(3C) of /proc should list /proc/self

Added by Rich Lowe 3 months ago. Updated 3 months ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
kernel
Start date:
Due date:
% Done:

0%

Estimated time:
Difficulty:
Medium
Tags:
Gerrit CR:
External Bug:

Description

It appears that listing /proc doesn't include the /proc/self magic symlink. It would help discoverability if it was there.

; /bin/ls /proc
0      20741  24334  25253  25499  26003  26034  26074  26099  3      737
; /bin/ls /proc/self/
as         ctl        ldt        lwp        path       root       usage
auxv       cwd        lpsinfo    map        priv       secflags   watch
contracts  fd         lstatus    object     psinfo     sigact     xmap
cred       fdinfo     lusage     pagedata   rmap       status
Actions #1

Updated by Rich Lowe 3 months ago

proc(5) says

     A given directory /proc/pid contains the following entries.  A process
     can use the invisible alias /proc/self if it wishes to open one of its
     own /proc files (invisible in the sense that the name “self” does not
     appear in a directory listing of /proc obtained from ls(1), getdents(2),
     or readdir(3C)).

but not why. An attempt to be compatible with someone listing pids that way?

Actions #2

Updated by Joshua M. Clulow 3 months ago

I am worried about this from a compatibility perspective. I have definitely written things that did cd /proc && echo * to get a list of pids.

Actions

Also available in: Atom PDF