8.8 wait3和wait4函数-进程控制

8.8 wait3wait4函数-进程控制

wait3wait4提供的功能比waitwaitpidwaitid所提供的功能要多一个,这与附加参数rusage有关。该参数要求内核返回由终止进程及其所有子进程使用的资源汇总。

#include <sys/types.h>

#include <sys/wait.h>

#include <sys/time.h>

#include <sys/resource.h>

pid_t wait3(int *statloc, int options, struct rusage *rusage);

pid_t wait4(pid_t pid, int *statloc, int options, struct rusage *rusage);

//两个函数返回值:若成功返回进程ID,若出错则返回-1

资源统计信息包括用户CPU时间总量、系统CPU时间总量、页面出错次数、接收到信号的次数等。有关细节参阅getrusage(2)手册页。

8 - 5中列出了各个wait函数所支持的不同的参数。

函数

pid

options

ru s a g e

POSIX.1

Free BSD 5.2.1

Linux 2.4.22

Mac OSX 10.3

Solaris 9

wait

 

 

 

·

·

·

·

·

waited

·

·

 

 

 

 

 

·

waitpid

·

·

 

·

·

·

·

·

wait 3

 

·

·

 

·

·

·

·

wait 4

·

·

·

 

·

·

·

·

 

posted @ 2011-10-19 19:43  郭—大—侠  阅读(468)  评论(0编辑  收藏  举报