Sending an EOF to a named pipe

  • Follow


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
0
Reply Daniel 4/11/2008 7:41:09 PM

Daniel Ganek wrote:

> 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?

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.          ------


0
Reply Lew 4/11/2008 9:48:02 PM


Lew Pitcher wrote:
> Daniel Ganek wrote:
> 
>> 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?
> 
> 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
0
Reply Daniel 4/14/2008 2:42:17 PM

Lew Pitcher <lpitcher@teksavvy.com> writes:

< Daniel Ganek wrote:
>
>> 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

a stab in the dark says `echo -en "\004"'  may help but doubtful. At ^Z may
work.

kill -l may help? Sighup? dunno.


0
Reply Stephen 5/25/2008 5:18:53 AM

Stephen Gonedes wrote:
> Lew Pitcher <lpitcher@teksavvy.com> writes:
> 
> < Daniel Ganek wrote:
>>> 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
> 
> 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

0
Reply propman 5/25/2008 7:49:57 PM

4 Replies
474 Views

(page loaded in 0.111 seconds)

Similiar Articles:













7/24/2012 6:05:48 AM


Reply: