user7898461
user7898461

Reputation:

Determine who is listening on fifo named pipe

Say I have a named pipe:

mypipe="foobar"
mkfifo $mypipe

... later on say I want to write to it

echo "foo" > $mypipe

if nobody is listening, I am pretty certain this echo call just hangs. Is there a way to determine if anyone is reading from the pipe before I make the echo call?

Upvotes: 1

Views: 499

Answers (1)

tripleee
tripleee

Reputation: 189830

The fuser utility tells you who holds an open handle, but in the general case, it requires root privileges.

Quoting the manual page,

fuser may only be able to gather partial information unless run with privileges. As a consequence, files opened by processes belonging to other users may not be listed and executables may be classified as mapped only.

Installing fuser SUID root will avoid problems associated with partial information, but may be undesirable for security and privacy reasons.

Upvotes: 1

Related Questions