command pipe concatenated messages
Al Tobey
albert.tobey at priority-health.com
Mon Dec 29 17:49:39 CET 2003
On Mon, 2003-12-29 at 06:06, Jim Mozley wrote:
> John P. Rouillard wrote:
>
>
> > I would use ">> $pipe" to append data for two reasons:
Jim was my beta tester for Nagios::Cmd when working out the bugs on
Solaris (actually, any BSD flavor). BSD's don't allow seek() on fifos
and opening in O_APPEND mode implies a seek to the end of the file,
which throws an exception. Linux happily ignores the seek().
> >
> > 1 - > clobbers data already existing in files, not sure about in pipes
O_TRUNC is ignored for terminals and FIFO's - see the open(2) manpage.
> > 2 - atomic writes occur only if file is opened for append IIRC.
FIFO's cannot be opened in append mode on BSD flavors, as I explained
earlier.
> >
> >>flock(PIPE, LOCK_EX);
> >
> >
> > This should guarantee only one process is accessing the file, but I
> > think you have already written to the file by using > in your open, so
> > there may be a race condition.
Well, that write you're worried about doesn't occur since O_TRUNC is
ignored for FIFO's. No race condition :)
> IIRC it is not possible to open a filehandle to a pipe using ">> $pipe",
> one must use "> $pipe". I get "Cannot open pipe Illegal seek at ..."
> when trying.
Ahh, the rigors and wonders of portability.
> Regards,
>
> Jim
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by: IBM Linux Tutorials.
> Become an expert in LINUX or just sharpen your skills. Sign up for IBM's
> Free Linux Tutorials. Learn everything from the bash shell to sys admin.
> Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click
> _______________________________________________
> Nagios-devel mailing list
> Nagios-devel at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/nagios-devel
** ** ** PRIVILEGED AND CONFIDENTIAL ** ** **
This email transmission contains privileged and confidential information
intended only for the use of the individual or entity named above. Any
unauthorized review, use, disclosure or distribution is prohibited and
may be a violation of law. If you are not the intended recipient or a
person responsible for delivering this message to an intended recipient,
please delete the email and immediately notify the sender via the email
return address or mailto:postmaster at priority-health.com. Thank you.
-------------------------------------------------------
This SF.net email is sponsored by: IBM Linux Tutorials.
Become an expert in LINUX or just sharpen your skills. Sign up for IBM's
Free Linux Tutorials. Learn everything from the bash shell to sys admin.
Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click
More information about the Developers
mailing list