- status
- The low-order eight bits of status are generally made available to a parent process.
The exit function terminates a process.
Before termination, exit() performs the following functions in the order listed:
The low-order eight bits of the status argument is made available to a parent process which has called a Syscall.wait(2)-family function.
The C Standard (ISO/IEC 9899:1999 ("ISO C99")) defines the values 0, Stdlib.EXIT_SUCCESS, and Stdlib.EXIT_FAILURE as possible values of status. Cooperating processes may use other values; in a program which might be called by a mail transfer agent, the values described in sysexits(3) may be used to provide more information to the parent process.
Note that exit() does nothing to prevent bottomless recursion should a function registered using Stdlib.atexit(3) itself call exit(). Such functions must call Stdlib._Exit() instead (although this has other effects as well which may not be desired).
This function never returns.
C# Example
using System;
using Mono.Unix.Native;
using System.Runtime.InteropServices;
class Test
{
public void SignalCatcher(int v)
{
// sleep signal caught.
Console.WriteLine("Signal received: " + v);
// this line will not be printed because process exits...
Console.WriteLine("Exiting with: " + Stdlib.exit(9));
}
public static void Main(string[] args)
{
Test t = new Test();
Console.Write("waiting for event...");
string x = Console.ReadLine();
}
public Test()
{
// create a signal handler delegate for sleep signals
Console.WriteLine("signal result: " +
Syscall.signal(Signum.SIGALRM,
new SignalHandler (SignalCatcher)));
// send a sleep signal
Syscall.alarm(3);
}
}