From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: To: 9fans@cse.psu.edu Subject: Re: [9fans] waitfor() call question? From: Joel “chesky” Salomon Date: Thu, 12 Oct 2006 21:27:22 -0400 In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Topicbox-Message-UUID: c97a0a14-ead1-11e9-9d60-3106f5b1d025 > 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=E2=80=99s book (http://lsub.org/who/nemo/9.intro.pdf, page 91) gives= code for waiting for a particular descendant process if that=E2=80=99s what=E2= =80=99s wanted. Actually, he uses it for the immediate child process, which makes me wonder=E2=80=94after the child process has exited, can the paren= t wait() for a grandchild? Just for fun: Waitmsg * waitfor(int pid) { Waitmsg *m; while(m =3D wait()){ if(m->pid !=3D 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=E2=80=99re asked for=E2=80=94or 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 =E2=98=BA) Why is waitfor() =E2=80=9Coccasionally unavoidable=E2=80=9D on UNIX? --Joel