[lug] named pipe missunderstanding

Jason Davis jdavis at openactive.org
Wed Feb 2 14:08:31 MST 2011


Seems to work fine if I keep the connection open. Writing and reading
work as expected. I dont plan on trying to seek() or do other file
operations. What exactly can I not rely on?


On Wed, Feb 2, 2011 at 9:47 AM, Lori Reed <lorireed at lightning-rose.com> wrote:
> On 02/02/2011 09:12 AM, Jason Davis wrote:
>
>> Thanks for the replies. Im pretty sure I can treat named pipes like
>> any other file.
>
> Yes, popen(3) returns a pointer to type FILE (as does fopen(3)) , so you
> can use any of the FILE stream functions with pipes (ie: fgets(3),
> fputs(3), etc).
>
> But you *cannot* rely on files to behave as pipes. You might get away
> with it, but you can't rely on it.
>
> Unless the FILE stream is opened with popen(3), then it's *not* a pipe.
>
>> Someone suggested that
>> when a process closes the fifo that any data not cunsumed yet will be
>> lost. This would explain what Im seeing,
>
> Maybe, but it doesn't matter as using files as pipes is the wrong
> approach. If there are no true IPC pipes classes in Java, then you need
> to use something else for IPC. Shared memory and sockets are two
> possibilities.
>
> Lori
>
> _______________________________________________
> Web Page:  http://lug.boulder.co.us
> Mailing List: http://lists.lug.boulder.co.us/mailman/listinfo/lug
> Join us on IRC: irc.hackingsociety.org port=6667 channel=#hackingsociety
>



More information about the LUG mailing list