[PATCH] Document /proc/TGID /proc/TID readdir weirdness

From: Nikanth Karthikesan
Date: Tue Jul 14 2009 - 04:46:39 EST


readdir() on /proc returns only one directory per TGID, i.e., /proc/<TGID>
But if you, try to read a directory /proc/<TID>/ where there is no TGID == TID,
it would succeed.

For example,
$ ls /proc
There is no directory by name /proc/6375

$ ls /proc/6373/task
6373 6375

$ ls /proc/6375/
attr cmdline environ io maps ...
/proc/6375/ exists!

I tried changing this behaviour to disallow reads using /proc/<TID>/, but it
breaks, a lot of user-space applications and scripts that depend on this
behaviour. So let us make this a documented behaviour.

Signed-off-by: Nikanth Karthikesan <knikanth@xxxxxxx>

---
diff --git a/Documentation/filesystems/proc.txt b/Documentation/filesystems/proc.txt
index fad18f9..ae79898 100644
--- a/Documentation/filesystems/proc.txt
+++ b/Documentation/filesystems/proc.txt
@@ -137,8 +137,14 @@ Table 1-1: Process specific entries in /proc
stack Report full stack trace, enable via CONFIG_STACKTRACE
smaps a extension based on maps, showing the memory consumption of
each mapping
+ task Contains directories for each thread in this thread group. Each
+ of those directory contain similar information specific for
+ those threads. /proc/<TGID>/task/<TID>
..............................................................................

+NOTE: Even though readdir() on /proc returns only one directory per TGID it is
+possible to open and read /proc/<TID>/ directly, using any TID as well.
+
For example, to get the status information of a process, all you have to do is
read the file /proc/PID/status:




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