Re: open FIFO erro



On 2006-09-25, freegnu <freegnu@xxxxxxx> wrote:
hi all , i have a test program, which the prarent process write "hello
world" to a FIFO , and the child process read it form the FIFO,and printf it
on the screem.
but when i run the test program, it open the FIFO,there some problem happen.
the prarent process hand up on open(), and
the child process has error take place


You must open the fifo for reading before you attempt to write to it for writing.

man 3 mkfifo
man 4 fifo



It's probably safest to open it before the fork and then close the reader
in the fork where it's not needed.

also.

if(EEXIST == errno)printf("pEEXIST\n");
if(EACCES == errno)printf("pEACCES\n");
if(EROFS == errno)printf("pEROFS\n");
if(EFAULT == errno)printf("pEFAULT\n");
if(EINVAL == errno)printf("pEINVAL\n");
if(ENAMETOOLONG == errno)printf("pENAMETOOLONG\n");
if(ENOTDIR == errno)printf("pENOTDIR\n");
if(ENOMEM == errno)printf("pENOMEM\n");
if(ELOOP == errno)printf("pELOOP\n");
if(EIO == errno)printf("pEIO\n");


there's a neat standard function called "perror()"


this one may be worth a look too.

man 2 pipe

Bye.
Jasen
.



Relevant Pages

  • Re: using FIFO for IPC between parent & child
    ... > parent and child process. ... Opening a FIFO for both reading and writing and then also using ...
    (comp.unix.questions)
  • Re: signal race
    ... I'm trying to figure out how I can prevent a certain kind of race condition. ... wait for a child process ... because the open might be a fifo which has no ... signals. ...
    (comp.unix.programmer)
  • Re: using FIFO for IPC between parent & child
    ... Can i use FIFO for IPC between ... > parent and child process. ... A FIFO can be used for communication between any two processes, ...
    (comp.unix.questions)
  • Re: open FIFO erro
    ... If that is not the problem then the issue is with the fifo permissions. ... world" to a FIFO, and the child process read it form the FIFO,and printf it ... int real_wnum; ...
    (comp.os.linux.development.apps)
  • Re: timing a fork
    ... if ($kid) { ... That is why I want the child process to be detached. ... But, I'm new to modperl, and I think a fork doesn't copy the ... What it does is say that the parent isn't interested in ...
    (perl.beginners)