Understanding sudoers(5) syntax: a simple explanation (no EBNF)
toroid.org3 pointsby amenonsen1 comments
$ ls -l /proc/2760791/fd
total 0
lrwx------ 1 ams ams 64 Mar 28 13:35 0 -> /dev/pts/10
l-wx------ 1 ams ams 64 Mar 28 13:35 1 -> pipe:[54074122]
lrwx------ 1 ams ams 64 Mar 28 13:35 2 -> /dev/pts/10
$ ls -l /proc/2760792/fd
total 0
lr-x------ 1 ams ams 64 Mar 28 13:35 0 -> pipe:[54074122]
lrwx------ 1 ams ams 64 Mar 28 13:35 1 -> /dev/pts/10
lrwx------ 1 ams ams 64 Mar 28 13:35 2 -> /dev/pts/10
Here 2760791 is the pid of the "sleep 600", and 2760792 is the pid of "wc". You can see they're both connected to "pipe:[54074122]". $ lsof -E -u ams|egrep 'sleep|wc'|grep pipe
sleep 2760791 ams 1w FIFO 0,13 0t0 54074122 pipe 2760792,wc,0r
wc 2760792 ams 0r FIFO 0,13 0t0 54074122 pipe 2760791,sleep,1w
But the name "pipe:[54074122]" is actually the "filename" of the pipe, and it comes from here in fs/pipe.c: static char *pipefs_dname(struct dentry *dentry, char *buffer, int buflen)
{
return dynamic_dname(dentry, buffer, buflen, "pipe:[%lu]",
d_inode(dentry)->i_ino);
}
(There's an interesting note in Documentation/filesystems/vfs.txt about how pseudo-filesystems like pipefs can generate these names only when someone asks for them, since they're not used for anything otherwise. The only way I know of to ask for the name in this case is to call readlink() on the pipe fd under /proc/$pid/fd, as ls does.) /*
* This file contains a high-performance replacement for the socket-based
* pipes scheme originally used in FreeBSD/4.4Lite. It does not support
* all features of sockets, but does do everything that pipes normally
* do.
*/ «On some systems (but not Linux), pipes are bidirectional:
data can be transmitted in both directions between the
pipe ends. POSIX.1 requires only unidirectional pipes.
Portable applications should avoid reliance on
bidirectional pipe semantics.»
I believe the systems that supported bidirectional pipes were SysV kernels that implemented pipes using STREAMS and 4(?)BSD kernels that implemented it using socketpair.