Re: Writing to a named pipe imposible if there is no reading process running
From: Michael Kerrisk (michael-dot-kerrisk-at-gmx-dot-net_at_NOSPAM.COM)
Date: 12/08/03
- Next message: Christopher M. Lusardi: "How can I get variable info from an executable file? (nm/objdump etc)"
- Previous message: Thanassis Dolmatzis: "Writing to a named pipe imposible if there is no reading process running"
- In reply to: Thanassis Dolmatzis: "Writing to a named pipe imposible if there is no reading process running"
- Next in thread: John Reiser: "Re: Writing to a named pipe imposible if there is no reading process running"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 08 Dec 2003 17:05:34 +0100
On 8 Dec 2003 07:47:50 -0800, sinefula@web.de (Thanassis Dolmatzis)
wrote:
>Wondering why I am the only programmer having this trouble, here is my
>unsolvable problem.
>Porting my C-Programms to SuSE Linux Enterprse Server8 was no big deal
>except that:
>I have a named pipe called "protpipe" and one process runing, reading
>out of that pipe and writing the contents to a text file.
>Whith this concept any process writing in this pipe will get its text
>writen in the correct order in the text file without los of data.
>On HP-UX and other Unix derivates, the writing processes had the
>oportunity to write to that pipe even when the reading process wasn't
>running.
Without seeing the code, it's hard to say for sure, but what you are
describing is non-standard behaviour (though I've seen implementations
-- not specifically HP-UX -- that do this).
>In that case an "ls -l protpipe" showed the size of the
>writen bytes.
And that is definitely non-standard behaviour, though again I have
known some implementations that did the same (and Linux 2.2 also used
to do that, but not 2.4 and later).
>When i there after startet the reading process, the contents of the
>pipe get in the text file as expectet.
>I didn't found on Linux a way doing the same: If I try to write in to
>the pipe when the reading process does not exist, the writing process
>breaks up writing, or blocks depending on the Flags I set in the
>"open()" system call.
Standard behaviour wjhen opening a FIFO is this: opening a FIFO for
reading blocks until another process opens the FIFO for writing;
opening the FIFO for writing blocks until another process opens the
FIFO for reading. If the opposite end of a FIFO is already open
(perhaps because a pair of processes have already opened each end of
the FIFO), then open() succeeds immediately.
The O_NONBLOCK flag can be used to do a non-blocking open():
- If opening a FIFO for reading, and no process currently has the
write end of the FIFO open, then the open() call succeeds immediately.
- If opening a FIFO for writing, and the other end of the FIFO is not
already open for reading by another process, then open() fails.
>Hoping You understand my English,
kein Problem
>P.S.:If necessary I could copy the coding in to the message.
Can you cut it down to something minumal that demonstrates your
problem? If so, post it.
Cheers,
Michael
- Next message: Christopher M. Lusardi: "How can I get variable info from an executable file? (nm/objdump etc)"
- Previous message: Thanassis Dolmatzis: "Writing to a named pipe imposible if there is no reading process running"
- In reply to: Thanassis Dolmatzis: "Writing to a named pipe imposible if there is no reading process running"
- Next in thread: John Reiser: "Re: Writing to a named pipe imposible if there is no reading process running"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|