Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

There is a contract for the use of a named pipe. I will suppose un*xlike and to simplify I will not talk about non-blocking. For pipes the default is blocking.

  • You need a reader and usually the reader is a long-running process.
  • The reader will block on read as soon as it opens. If there is no reader any writer will block.
  • Remember it *is* a pipe so what gets in must get out... If you write more than a certain maximum number of bytes input is likely to be intermixed between the writers. If the reader does not process the input quickly enough then eventually a writer will be blocked and then all the other writers, so you need some flow analysis or special janitor processes.

    So do you have a permanent reader? If you have a read-once reader the behavior you seem to be experiencing is *normal*. Can it be somehow that the pipe is opened by the two threads? Can you check with lsof or similar the processes that maintain a descriptor opened to the named pipe. If you had posted some code we might have been able to help better.

    % steph@ape (/home/stephan) % % cat reader.sh #!/bin/ksh trap 'exit 0' INT pipe=named_pipe outfile=out [[ -p $pipe ]] || mkfifo $pipe exec 0<$pipe while dd if=$pipe bs=64 count=1 >> $outfile do print .processing sleep 2 done % steph@ape (/home/stephan) % % jobs [1] + Running ./reader.sh &
    cheers --stephan

    In reply to Re: named pipe and "Text file busy" by sgt
    in thread named pipe and "Text file busy" by finpro

    Title:
    Use:  <p> text here (a paragraph) </p>
    and:  <code> code here </code>
    to format your post; it's "PerlMonks-approved HTML":



    • Are you posting in the right place? Check out Where do I post X? to know for sure.
    • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
      <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
    • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
    • Want more info? How to link or How to display code and escape characters are good places to start.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Domain Nodelet?
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this?Last hourOther CB clients
    Other Users?
    Others scrutinizing the Monastery: (4)
    As of 2024-04-23 06:01 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      No recent polls found