From: Joel âcheskyâ Salomon <chesky@plan9.jp>
To: 9fans@cse.psu.edu
Subject: Re: [9fans] waitfor() call question?
Date: Thu, 12 Oct 2006 21:27:22 -0400 [thread overview]
Message-ID: <e05cb1dde77f831e8cc594d5b40591fd@plan9.jp> (raw)
In-Reply-To: <ee9e417a0610121450l1c8bcb55g779f839b984ece5c@mail.gmail.com>
> 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
next prev parent reply other threads:[~2006-10-13 1:27 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-10-12 21:34 ISHWAR RATTAN
2006-10-12 21:50 ` Russ Cox
2006-10-13 1:27 ` Joel “chesky” Salomon [this message]
2006-10-13 3:00 ` Russ Cox
2006-10-13 8:43 ` Bruce Ellis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e05cb1dde77f831e8cc594d5b40591fd@plan9.jp \
--to=chesky@plan9.jp \
--cc=9fans@cse.psu.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).