Writes to a pipe are atomic as long as they are short enough. This atomic size can be found in your systems header files as the constant PIPE_BUF, and it's defined by posix to be at least 512 bytes (on linux for example it's 4096 bytes). At the perl level the constant can be found in POSIX.pm:
perl -wle 'use POSIX; print PIPE_BUF'

So if you make sure that your filehandle to the pipe is autoflushing (so that perl prints become one write), the filehandle isn't unbuffered (normally only a problem with STDERR, in that case make sure your print doesn't consist of many pieces) and your message is short enough (<= 512 bytes), you're safe.


In reply to Re: Using pipe with more than one child process by thospel
in thread Using pipe with more than one child process by Anonymous Monk

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.