This, as the experts among you must know by now, doesn't work. The
server is created, but the flow seems to freeze at the open() on the server
side. BTW, I understand that I have to use the NONBLOCK option here.
Can anyone help? Thanks.
Hi Julio,
If you fork()/exec() and wait() in the parent-process, the parent is blocked until
the child terminates. But this is not what you want.
I've the an unlink() mkfifo()...this will be difficult to handle, because if the parent might have already
opened the fifo you're just deleting.
Better (more reliable) will be a construction like this:
parent:
int loop,rc;
for (loop=0,rc=-1; loop<10 && rc==-1; loop++)
{
rc=open("fifo",rdonly);
if (rc<0) sleep(1);
}
son:
mkfifo("fifo",...); /* don't check returncode, coz if it already exists, this call will fail *?
fd=open("fifo",wronly); /* you dont need nonblock...this way the child will syncronize with the father */
regards Rainer
>server is created, but the flow seems to freeze at the open() on the server
>side.
Because the waitpid() is waiting for the child to exit. You
either need to delay this waitpid() call until you are expecting
the child to die (such as if you use the double-fork technique
for starting the child), or do a non-blocking form of waitpid()
(i.e., set the third argument to WNOHANG).
--Ken Pizzini