Skip to contentSkip to conversation

Question regarding /proc/<pid>/fd and pipes

DISCUSSION Bodo Eggert 4 participants 4 messages Feb 8, 2006 – Feb 9, 2006 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw
Quoted 4 lines · John Schmerge

I know that the symlinks in the /proc/<pid>/fd directory point to
bogus filenames for pipes (i.e. 'pipe:[64682]') and am wondering if every process that reads and writes from that pipe will share the same bogus symlink name.

yes

Quoted 2 lines

In essence, I'm wondering if there's any way to list all of the pid's
of processes using an anonomous pipe.

man find. I don't know a bettre way.

Signature · 2 lines
Ich danke GMX dafür, die Verwendung meiner Adressen mittels per SPF
verbreiteten Lügen zu sabotieren.
#2 lore raw

Bodo,

Thanks for the answer... I've got one more question: will the symlinks to the pipe be the same for both the read and write ends in all processes sharing the pipe?

I've got some sort of funky race condition occurring between the read from the pipe and the exiting of the process on the write-end of the pipe... The read-process is supposed to exit after the write-process finishes (and does in about 1/2 the time), but I think I'm seeing the read-process blocked by something even after the write-process completes... Both top and ps give no indication that the read-process is blocked on a read(2). I've got some digging to do, but I'm thinking that this might actually be a kernel bug.

Thanks,
John

Quoted 17 lines · Bodo Eggert
Quoted 4 lines · John Schmerge

I know that the symlinks in the /proc/<pid>/fd directory point to
bogus filenames for pipes (i.e. 'pipe:[64682]') and am wondering if every process that reads and writes from that pipe will share the same bogus symlink name.

yes

Quoted 2 lines

In essence, I'm wondering if there's any way to list all of the pid's
of processes using an anonomous pipe.

man find. I don't know a bettre way.
--
Ich danke GMX daf�r, die Verwendung meiner Adressen mittels per SPF verbreiteten L�gen zu sabotieren.

#3 lore raw
Quoted 3 lines · John Schmerge

Thanks for the answer... I've got one more question: will the symlinks to the pipe be the same for both the read and write ends in all processes sharing the pipe?

It seems like yes. You can find it out by sinply trying it out.

Quoted 8 lines

I've got some sort of funky race condition occurring between the read from the pipe and the exiting of the process on the write-end of the pipe... The read-process is supposed to exit after the write-process finishes (and does in about 1/2 the time), but I think I'm seeing the read-process blocked by something even after the write-process completes... Both top and ps give no indication that the read-process is blocked on a read(2). I've got some digging to do, but I'm thinking that this might actually be a kernel bug.

Do you close() the writing end in the process that's supposed to read?

Signature · 2 lines
Top 100 things you don't want the sysadmin to say:
98. What the hell!?
#4 lore raw
In reply to Bodo Eggert
Quoted 6 lines
Quoted 5 lines

I know that the symlinks in the /proc/<pid>/fd directory point to
bogus filenames for pipes (i.e. 'pipe:[64682]') and am wondering if every process that reads and writes from that pipe will share the same bogus symlink name.

It is not really bogus. And it is not really real at the same time. This is how it works AFAIU: pipes get created in pipefs (cat /proc/filesystems) (as do sockets in sockfs), and their dentry IS named "pipe:[46682]". You just can't see it because 1. you are prevented from mounting pipefs, 2. there are no readdir/etc. functions for pipefs implemented ATM.

Quoted 3 lines
Quoted 2 lines

In essence, I'm wondering if there's any way to list all of the pid's
of processes using an anonomous pipe.

Hm. Do you mean list "all pids of procs using an anynymous pipe" or "list all pids [...]" using an anonymous pipe... :)

AFAICS, the first is not possible; the latter is (a fork-and-exec thing) is something different.

Jan Engelhardt