|
Home > Archive > Unix Programming > November 2006 > PIPE
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
| nileshsimaria@gmail.com 2006-11-28, 7:30 am |
| Suppose I have a Parent process (P) and Chile process (C). There exists
a pike between them, P is suppose to read from pipe and C is suppose to
write into pipe.
Now suppose P is calling read() on pipe but pipe is empty, since it
blocking call P will wait for data to come. Assume before C writes to
pipe it crashes. What will happen to P ? By any chance it will get some
notification to that it could come out of blocking call ?
Thanks,
Nilesh
| |
| Christophe Leitienne 2006-11-28, 7:30 am |
| Hi,
> Suppose I have a Parent process (P) and Chile process (C). There exists
> a pike between them, P is suppose to read from pipe and C is suppose to
> write into pipe.
>
> Now suppose P is calling read() on pipe but pipe is empty, since it
> blocking call P will wait for data to come. Assume before C writes to
> pipe it crashes. What will happen to P ? By any chance it will get some
> notification to that it could come out of blocking call ?
>
If C crashes, then its side of the pipe will close. Assuming you have
closed the writing descriptor (aka filedes[1]) in P, then
read(filedes[0]) in P will return 0 (notification that the writing side
of the pipe has been closed).
So P will not block if P stops for some reason.
Chris.
| |
| Casper H.S. Dik 2006-11-28, 7:30 am |
| nileshsimaria@gmail.com writes:
>Suppose I have a Parent process (P) and Chile process (C). There exists
>a pike between them, P is suppose to read from pipe and C is suppose to
>write into pipe.
>Now suppose P is calling read() on pipe but pipe is empty, since it
>blocking call P will wait for data to come. Assume before C writes to
>pipe it crashes. What will happen to P ? By any chance it will get some
>notification to that it could come out of blocking call ?
It gets an EOF (read returns NULL) provided that you closed the other
end of the pipe.
Casper
--
Expressed in this posting are my opinions. They are in no way related
to opinions held by my employer, Sun Microsystems.
Statements on Sun products included here are not gospel and may
be fiction rather than truth.
|
|
|
|
|