Philip Silva via 9fans <9fans@9fans.net> once said:
>         if ((cpid = fork()) != 0) {
>                 close(infd[1]);
>                 close(outfd[1]);
>
>                 n = write(infd[0], "test", 4);
>                 printf("check process: wrote %d bytes\n", n);
>
>                 sendnote(cpid);
>                 // close(infd[0]);  // <--- uncomment to make write fail
>                 // close(outfd[0]);
>
>                 n = write(infd[0], "test2", 5);
>                 printf("write: wrote %d bytes\n", n);
>
>                 n = read(outfd[0], outbuf, 20);
>                 printf("outbuf=%s (n=%d)\n", outbuf, n);
>                 wait();
>                 return 0;

Why aren't you waiting for the process to die
after sending it the note? It must be running
to see that is has a note pending. At the time
of your second write, the scheduler may not
have selected the child process to run.

The sequence could look like:

child: read from empty pipe, go to sleep
parent: write to pipe
parent: write kill to /proc/$cpid/note
parent: write to pipe
child: wakeup, see note, die

Cheers,
  Anthony

------------------------------------------
9fans: 9fans
Permalink: 
https://9fans.topicbox.com/groups/9fans/T3392001a02ee7ec8-Mfe03d0d140063db1ea509f2a
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription

Reply via email to