michile

导航

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.

posted on 2013-02-02 23:18  michile  阅读(164)  评论(0编辑  收藏  举报