wait 信号

Posted Think

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了wait 信号相关的知识,希望对你有一定的参考价值。

1、wait阻塞父进程,没有子进程或SIGCHLD set to SIG_IGN 会失败,until status information for one of the terminated child processes of the calling process is available, or until delivery of a

signal whose action is either to execute a signal-catching function or to terminate the process.

2、status 什么时候是0:

The process returned 0 from main().

The process called _exit() or exit() with a status argument of 0.

The process was terminated because the last thread in the process terminated.

3、WIFEXITED(stat_val)

Evaluates to a non-zero value if status was returned for a child process that terminated normally.  包括stat_val是0;但0是正常退出,其他exit(2)等退出。

WEXITSTATUS (status); 只有stat_val== 0 才有意义。其他的比如signal的退出也都是0;

4、WIFSIGNALED(stat_val)

Evaluates to a non-zero value if status was returned for a child process that terminated due to the receipt of a signal that was not caught (see <signal.h>).

WTERMSIG(stat_val)

If the value of WIFSIGNALED(stat_val) is non-zero, this macro evaluates to the number of the signal that caused the termination of the child process.

5、信号的status id号和exit的不同。

 

以上是关于wait 信号的主要内容,如果未能解决你的问题,请参考以下文章

wait 信号

信号线程上的 WaitForSingleObject 给出 WAIT_FAILED,为啥?

二十Linux 进程与信号---wait 函数

奇怪的 POSIX 信号量行为(卡在 Linux 上的 sem_wait 上)

sem_wait sem_post信号量操作进本函数

在信号句柄中使用 pthread_cond_wait 的 Pthread 被阻塞