emm..... I would give you 75
out of 100 for your code.
The basic infrastructure was right, but there are two fatal errors.
1) A pipe can only be used to either read or write by a process, but not
both, otherwise, you would confuse the STREAMS(although it's not
gonna crash). so the parent process should have used the fd
to write , and the child process should have used the fd to read.
2) It's very important that you close the other descriptor that you don't
need, otherwise you would never know when the other side closes
the connection, because you always have a connection open to
yourself, the read() function will return zero on a reading end of
pipe only when all connections to the writing end have been closed.
I'm going to the picnic on Saturday, see you then...
This post has been archived. It cannot be replied.