* FIFO question
@ 2005-01-06 12:27 Eric Bambach
2005-01-09 6:34 ` Eric Bambach
0 siblings, 1 reply; 2+ messages in thread
From: Eric Bambach @ 2005-01-06 12:27 UTC (permalink / raw)
To: linux-c-programming
Hello,
This is the first time I am using named pipes. I have a process with this C++
code that creates a named pipe and loops on writing the character "2" to it.
stringstream ssbuffer;
string buffer;
int pipeFD;
while (true){
pipeFD = open("my_pipe", O_WRONLY);
ssbuffer << 2;
buffer = ssbuffer.str();
write( pipeFD, buffer.c_str(), 1 );
close(pipeFD);
}
It happily sits on the pipe. When I open up another console and type "cat
my_pipe" it prints an arbitrary number of 2s. Usually many tens of them. From
what I read I thought that when I close the pipe using the close() call then
the readers will quit. Furthermore the main program doesnt receive a broken
pipe after the reader quits like it should. This is test code and I want just
ONE "2" to be read by cat. Perhaps I am missing something simple? Can anyone
enlighten me?
I plan to have only one reader and one writer on the pipe at a time so
synchronization is not neccesary.
I have also tried nanosleeping after the close. It seems sleep(1) fixes the
problem, but the main program still doesnt get a broken pipe after cat exits
and this causes an unacceptable and unpredicate delay before the start of the
read.
Futhermore I have also tried writing a very simple read program that tries to
read 10 bytes from the FIFO. It succeeds and actually gets 10 bytes from the
FIFO! Shouldnt the read be short because the main program called close after
1 byte?
----------------------------------------
--EB
> All is fine except that I can reliably "oops" it simply by trying to read
> from /proc/apm (e.g. cat /proc/apm).
> oops output and ksymoops-2.3.4 output is attached.
> Is there anything else I can contribute?
The latitude and longtitude of the bios writers current position, and
a ballistic missile.
--Alan Cox LKML-December 08,2000
----------------------------------------
-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: FIFO question
2005-01-06 12:27 FIFO question Eric Bambach
@ 2005-01-09 6:34 ` Eric Bambach
0 siblings, 0 replies; 2+ messages in thread
From: Eric Bambach @ 2005-01-09 6:34 UTC (permalink / raw)
To: linux-c-programming
Fixed it.
On Thursday 06 January 2005 06:27 am, Eric Bambach wrote:
> Hello,
>
> This is the first time I am using named pipes. I have a process with this
> C++ code that creates a named pipe and loops on writing the character "2"
> to it.
---snip---
----------------------------------------
--EB
> All is fine except that I can reliably "oops" it simply by trying to read
> from /proc/apm (e.g. cat /proc/apm).
> oops output and ksymoops-2.3.4 output is attached.
> Is there anything else I can contribute?
The latitude and longtitude of the bios writers current position, and
a ballistic missile.
--Alan Cox LKML-December 08,2000
----------------------------------------
-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2005-01-09 6:34 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-01-06 12:27 FIFO question Eric Bambach
2005-01-09 6:34 ` Eric Bambach
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).