> I am trying to figure out the meaning of: > > /proc/$PID/fd/* > > files.
These are links that point to the open files of the process whose pid is $PID. Fd stands for "file descriptors", which is an integer that identifies any program input or output in UNIX-like systems. > and then if I tried something like this: > > echo "foo" > /proc/$PID/fd/0 > [..] > What actually happened was: > - "foo" string appeared on the appropriate terminal > - the "./main" process remained blocked in the "read" system call. You program has the terminal opened as file descriptor 0 which corresponds to standard input (1 and 2 are standard output and standard error). If you list /proc/$PID/fd you will see something like this: $ ls -l /proc/$PID/fd/0 lrwx------ 1 root root 64 Fev 19 11:55 0 -> /dev/pts/7 meaning that your program has opened "pseudo terminal" 7 (probably an xterm) as its standar input. So when you write to /proc/$PID/fd/0, you are really writing to /dev/pts/7, that's why you see things appearing to the terminal. You cannot write to the standard input the way you thought because it is already linked to the terminal. Only the terminal can write to your program's standar input. > Is there somewhere a concise and correct description that explains this? I learned a lot about those subjects in the book Linux A-Z by Phil Cornes, but I think that /proc in Linux is becoming very specific. You have to learn a lot in man pages, kernel documentations, google, etc. Best wishes, João Luis. -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/bd4ac4a5bd11ade6eaac504064f4e533.squir...@nonada.if.usp.br