advancing linux program exit [copy]

In fact, you should use exit codes only between zero and 127. Exit codes above 128 have
a special meaning—when a process is terminated by a signal, its exit code is 128 plus
the signal number.

To send a signal from a program, use the killfunction.The first parameter is the tar-get process ID.The second parameter is the signal number; use SIGTERMto simulate the  default behavior of the killcommand. For instance, where child pidcontains the
process ID of the child process, you can use the killfunction to terminate a child
process from the parent by calling it like this:
kill (child_pid, SIGTERM);
Include the <sys/types.h>and <signal.h>headers if you use the killfunction.

原文地址:https://www.cnblogs.com/michile/p/2890533.html