JonsenElizee

Software Developing Blog

"An idea is fragile . It can be killed by a scornful smile or a yawn .It can be mound down by irony and scared to death by a cold look."
"Most cultures throughout human history have not liked creative individuals .They ignore them or kill them.It is a very efficient way of stopping creativity."

------Advertising boss Charles Browe and Howard Gardner ,professor at Harvard

   :: 首页 :: 新随笔 ::  ::  :: 管理 ::

#include <sys/types.h>
#include 
<sys/wait.h>

pid_t waitpid(pid_t pid, 
int* status, int options);

pid 
< -1 wait for any process with group id value = -pid;
pid 
= -1 same as wait();
pid 
= 0 wait for any subprocess of this process;
pid 
> 0 wait for process with it's id = pid;

options 
= 0 don't use options;
    WNOHANG  : just return if no subprocess finished.
    WUNTRACED: just 
return if subprocess is hanged up now.

status the 
return status of subprocess is stored in this int value.
    to make sure what happed, we can use following macro:
    WIFEXITED(status)      如果子进程正常结束则为非0值。
    WEXITSTATUS(status)    取得子进程exit()返回的结束代码,一般会先用WIFEXITED来判断是否正常结束才能使用此宏。
    WIFSIGNALED(status)    如果子进程是因为信号而结束则此宏值为真
    WTERMSIG(status)       取得子进程因信号而中止的信号代码,一般会先用WIFSIGNALED来判断后才使用此宏。
    WIFSTOPPED(status)     如果子进程处于暂停执行情况则此宏值为真。一般只有使用WUNTRACED时才会有此情况。
    WSTOPSIG(status)       取得引发子进程暂停的信号代码,一般会先用WIFSTOPPED来判断后才使用此宏。

return pid the subprocess id, else -1 for error, and errno is set.



posted on 2010-12-02 15:28 JonsenElizee 阅读(275) 评论(0)  编辑 收藏 引用

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理


By JonsenElizee