Discussion:
Sending an EOF to a named pipe
(too old to reply)
Daniel Ganek
2008-04-11 19:41:09 UTC
Permalink
I'm using named pipes in a bash script and I can't figure out how
to send an EOF so that the reader can exit.

I tried the obvious:

echo -e "\004" > mypipe

I also tried "rm mypipe"

Neither seems to generate an EOF

Anyone have any other ideas?

/dan
Lew Pitcher
2008-04-11 21:48:02 UTC
Permalink
Post by Daniel Ganek
I'm using named pipes in a bash script and I can't figure out how
to send an EOF so that the reader can exit.
echo -e "\004" > mypipe
I also tried "rm mypipe"
Neither seems to generate an EOF
Anyone have any other ideas?
Have the writer /close()/ the pipe

See the "I/O on Pipes and FIFOs" section of pipe(7) ("man 7 pipe")
"If all file descriptors referring to the write end of a pipe have
been closed, then an attempt to read(2) from the pipe will see
end-of-file (read(2) will return 0)."
--
Lew Pitcher

Master Codewright & JOAT-in-training | Registered Linux User #112576
http://pitcher.digitalfreehold.ca/ | GPG public key available by request
---------- Slackware - Because I know what I'm doing. ------
Daniel Ganek
2008-04-14 14:42:17 UTC
Permalink
Post by Lew Pitcher
Post by Daniel Ganek
I'm using named pipes in a bash script and I can't figure out how
to send an EOF so that the reader can exit.
echo -e "\004" > mypipe
I also tried "rm mypipe"
Neither seems to generate an EOF
Anyone have any other ideas?
Have the writer /close()/ the pipe
See the "I/O on Pipes and FIFOs" section of pipe(7) ("man 7 pipe")
"If all file descriptors referring to the write end of a pipe have
been closed, then an attempt to read(2) from the pipe will see
end-of-file (read(2) will return 0)."
OK, but how do I get bash to close a named pipe?

/dan
Stephen Gonedes
2008-05-25 05:18:53 UTC
Permalink
Post by Daniel Ganek
I'm using named pipes in a bash script and I can't figure out how
to send an EOF so that the reader can exit.
echo -e "\004" > mypipe
a stab in the dark says `echo -en "\004"' may help but doubtful. At ^Z may
work.

kill -l may help? Sighup? dunno.
propman
2008-05-25 19:49:57 UTC
Permalink
Post by Stephen Gonedes
Post by Daniel Ganek
I'm using named pipes in a bash script and I can't figure out how
to send an EOF so that the reader can exit.
echo -e "\004" > mypipe
a stab in the dark says `echo -en "\004"' may help but doubtful. At ^Z may
work.
kill -l may help? Sighup? dunno.
Did you try looking over the "advanced bash scripting guide" available
here (free):

http://tldp.org/guides.html

Loading...