Sending an EOF to a named pipe - Questions

This is a discussion on Sending an EOF to a named pipe - Questions ; 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 ...

+ Reply to Thread
Results 1 to 5 of 5

Thread: Sending an EOF to a named pipe

  1. Sending an EOF to a named pipe

    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

  2. Re: Sending an EOF to a named pipe

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



  3. Re: Sending an EOF to a named pipe

    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

  4. Re: Sending an EOF to a named pipe

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



  5. Re: Sending an EOF to a named pipe

    Stephen Gonedes wrote:
    > Lew Pitcher 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


+ Reply to Thread