[PATCH] proc.5: document ESRCH after process exit

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The following shell command demonstrates the openat, utimensat, lstat,
stat, unlink, and rmdir system calls failing with ESRCH:

    cd /proc/$(sleep 1 & echo $!) && { ls; touch foo; stat .; stat -L .; unlink foo; rmdir .; }

None of those system calls are documented as potentially returning that
error code. I think it would be unnecessarily tedious to document it in
each individual manual page (the list above is certainly incomplete),
but we can at least mention it as a catch-all in proc(5).
---

Notes:
    I’m not completely happy with the phrasing yet… I’m not sure if it’s
    sufficiently clear that it’s referring to operations that have some
    kind of handle on the directory (in the example of the commit
    message: the working directory), and not operations that try to
    access /proc/[pid] by absolute path (which results in ENOENT, as for
    any nonexistent directory). But I figured I’d send this patch and
    see what you think about it. (Perhaps this doesn’t need to be
    documented after all?)

 man5/proc.5 | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/man5/proc.5 b/man5/proc.5
index 55f3232a9..b8f6ef03a 100644
--- a/man5/proc.5
+++ b/man5/proc.5
@@ -188,6 +188,12 @@ The attribute was reset to the value in the file
 Resetting the "dumpable" attribute to 1 reverts the ownership of the
 .IR /proc/[pid]/*
 files to the process's real UID and real GID.
+.IP
+After a process exits, file system operations within its
+.I /proc/[pid]
+directory will fail with the error
+.BR ESRCH .
+This edge case is not documented in the manual pages of the individual system calls.
 .TP
 .I /proc/[pid]/attr
 .\" https://lwn.net/Articles/28222/
-- 
2.17.1

--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Kernel Documentation]     [Netdev]     [Linux Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux