[coyotos-dev] Behavior of exit()?
Neal H. Walfield
neal at walfield.org
Fri May 16 11:12:54 CDT 2008
At Thu, 15 May 2008 10:03:49 -0400,
Jonathan S. Shapiro wrote:
> There are several issues concerning exit() that need to be resolved in
> 1. How should exit() be handled? Is it an exception? If it is a
> "process exit status", where is this exit status delivered?
> Who gets the notification?
> 2. Do we want to have a coyotos variant of exit that exits with
> a result code?
Here's what I do on Viengoos, perhaps you'll find it helpful.
On Viengoos, it is possible to wait for an object's destruction. This
is done by queuing a message buffer on the object
(object->return_code). When destroying an object, it is possible to
provide a reason for its destruction (this is simply an integer, which
is uninterpreted by the kernel). This is sent to any message buffers
waiting on the object. Some objects, such as activities (think, space
bank), cause other objects to be destroyed implicitly. In this case,
those objects also return this integer. (I'm not yet sure this is a
good idea as it may lead to confusion: for instance, a grandchild's
forced exit should perhaps return something like SIGKILL.) exit uses
this mechanism to return the exit code; it destroys its main activity
and supplies the exit code as the reason. A parent process is able to
determine when a child exits and its exit code by queuing a message
buffer on the child's activity. It does this before the child starts
running to avoid the race where the child exits before the parent is
More information about the coyotos-dev