* [9fans] waitfor() call question?
@ 2006-10-12 21:34 ISHWAR RATTAN
2006-10-12 21:50 ` Russ Cox
0 siblings, 1 reply; 5+ messages in thread
From: ISHWAR RATTAN @ 2006-10-12 21:34 UTC (permalink / raw)
To: 9fans
Is it my imagination or there was a call
Waitmesg *waitfor(int pid);
in Plan 9? I can find it in Plan9ports but not
in Plan 9.
-ishwar
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [9fans] waitfor() call question?
2006-10-12 21:34 [9fans] waitfor() call question? ISHWAR RATTAN
@ 2006-10-12 21:50 ` Russ Cox
2006-10-13 1:27 ` Joel “chesky” Salomon
0 siblings, 1 reply; 5+ messages in thread
From: Russ Cox @ 2006-10-12 21:50 UTC (permalink / raw)
To: Fans of the OS Plan 9 from Bell Labs
> Is it my imagination or there was a call
> Waitmesg *waitfor(int pid);
>
> in Plan 9? I can find it in Plan9ports but not
> in Plan 9.
There was never a waitfor on Plan 9.
There is a waitpid, or perhaps (as you suggest)
you are thinking of the one I added for use on
Unix, where it is occasionally unavoidable.
Russ
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [9fans] waitfor() call question?
2006-10-12 21:50 ` Russ Cox
@ 2006-10-13 1:27 ` Joel “chesky” Salomon
2006-10-13 3:00 ` Russ Cox
0 siblings, 1 reply; 5+ messages in thread
From: Joel âcheskyâ Salomon @ 2006-10-13 1:27 UTC (permalink / raw)
To: 9fans
> There was never a waitfor on Plan 9.
> There is a waitpid, or perhaps (as you suggest)
> you are thinking of the one I added for use on
> Unix, where it is occasionally unavoidable.
Nemo’s book (http://lsub.org/who/nemo/9.intro.pdf, page 91) gives code
for waiting for a particular descendant process if that’s what’s
wanted. Actually, he uses it for the immediate child process, which
makes me wonder—after the child process has exited, can the parent
wait() for a grandchild?
Just for fun:
Waitmsg *
waitfor(int pid)
{
Waitmsg *m;
while(m = wait()){
if(m->pid != pid)
free(m);
else
return m;
}
return nil;
}
To better mimic lunix semantics, a real implementation probably ought
to remember all the other pids and return them when they’re asked
for—or rather would directly try to read process information from
/proc. (Reading the FreeBSD man page for wait(2)
(http://tinyurl.com/yy6tp2) is an educational experience in why Plan 9
is necessary ☺)
Why is waitfor() “occasionally unavoidable” on UNIX?
--Joel
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [9fans] waitfor() call question?
2006-10-13 1:27 ` Joel “chesky” Salomon
@ 2006-10-13 3:00 ` Russ Cox
2006-10-13 8:43 ` Bruce Ellis
0 siblings, 1 reply; 5+ messages in thread
From: Russ Cox @ 2006-10-13 3:00 UTC (permalink / raw)
To: Fans of the OS Plan 9 from Bell Labs
> Nemo's book (http://lsub.org/who/nemo/9.intro.pdf, page 91) gives code
> for waiting for a particular descendant process if that's what's
> wanted. Actually, he uses it for the immediate child process, which
> makes me wonder—after the child process has exited, can the parent
> wait() for a grandchild?
Nope.
> Why is waitfor() "occasionally unavoidable" on UNIX?
Because sometimes what would be multiple processes on Plan 9
is a single process on Unix, depending on the implementation of
the thread library, and two shared-memory procs each waiting for
their own children need not to get the other's child.
You could have some shared list of accidentally-waited-for children
but then the coordination to wake up the guy who is actually
waiting gets cumbersome.
Russ
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [9fans] waitfor() call question?
2006-10-13 3:00 ` Russ Cox
@ 2006-10-13 8:43 ` Bruce Ellis
0 siblings, 0 replies; 5+ messages in thread
From: Bruce Ellis @ 2006-10-13 8:43 UTC (permalink / raw)
To: Fans of the OS Plan 9 from Bell Labs
the culprit, not the scene of the crime.
brucee
On 10/13/06, Russ Cox <rsc@swtch.com> wrote:
> > Nemo's book (http://lsub.org/who/nemo/9.intro.pdf, page 91) gives code
> > for waiting for a particular descendant process if that's what's
> > wanted. Actually, he uses it for the immediate child process, which
> > makes me wonder—after the child process has exited, can the parent
> > wait() for a grandchild?
>
> Nope.
>
> > Why is waitfor() "occasionally unavoidable" on UNIX?
>
> Because sometimes what would be multiple processes on Plan 9
> is a single process on Unix, depending on the implementation of
> the thread library, and two shared-memory procs each waiting for
> their own children need not to get the other's child.
> You could have some shared list of accidentally-waited-for children
> but then the coordination to wake up the guy who is actually
> waiting gets cumbersome.
>
> Russ
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2006-10-13 8:43 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-10-12 21:34 [9fans] waitfor() call question? ISHWAR RATTAN
2006-10-12 21:50 ` Russ Cox
2006-10-13 1:27 ` Joel “chesky” Salomon
2006-10-13 3:00 ` Russ Cox
2006-10-13 8:43 ` Bruce Ellis
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).