home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.os.os9
- Path: sparky!uunet!europa.asd.contel.com!darwin.sura.net!haven.umd.edu!wam.umd.edu!ignatz
- From: ignatz@wam.umd.edu (Mark J. Sienkiewicz)
- Subject: Re: Deallocation of process descriptors.
- Message-ID: <1992Sep15.140540.13468@wam.umd.edu>
- Sender: usenet@wam.umd.edu (USENET News system)
- Nntp-Posting-Host: rac3.wam.umd.edu
- Organization: University of Maryland, College Park
- References: <1992Sep15.081851.10686@cs.nott.ac.uk>
- Date: Tue, 15 Sep 1992 14:05:40 GMT
- Lines: 48
-
- In article <1992Sep15.081851.10686@cs.nott.ac.uk> pczip@mips.nott.ac.uk (Ivan Powis) writes:
- >so the parent does not do a 'wait' for the child. This all works, but leaves
- >behind a trail of 'dead' non deallocated process descriptors until some
- >indefinite time in the future when the parent process is killed off. How can
- >I force these unwanted descriptors to be deallocated when the child terminates?
-
- This is the way it is supposed to work so you can find out exit statuses
- of your child processes.
-
- >It seems this situation is analogous to a shell creating background processes
- >with the 'command &' facility. The shell doesn't leave a trail of dead
- >descriptors in its wake, so there must be some way to achieve the desired
- >effect.
-
- This is because the shell does a wait every time you type a command that
- doesn't go into the background. For example, if you type 'procs' to
- see what is there, your shell will do a wait and get the status codes
- from the dead background process _before_ procs finds them in the process
- table.
-
- --
-
- What you need to do is to orphan the child processes. If the parent
- exits before the child, the child no longer has a parent and it's
- process table entry will be deallocated when it dies.
-
- To do this on OS9, you need a program that runs programs. The simplest
- way to do this is:
-
- parent()
- {
- system("child &");
- }
-
- Note that system() will create a shell. You tell the shell to run the
- program child _without_ waiting for it. The shell then immediately
- terminates. parent() ends up doing a wait() for a few ticks while the
- shell sets things up, but as soon as the shell is done, parent()
- _does_not_have_any_children_. But there is an orphaned process
- hanging around running "child". When child exits, there is no parent
- to report the exit status to, so it just goes away.
-
- I do the equivalent of this, but I have a special program that I use
- instead of the shell. It is just a call to os9fork() or os9exec() or
- something like that.
-
- Mark S.
-
-