wait4() - Unix,Linux 系統呼叫 - 技術教學
Tutorials Point


  Unix 初學者教程
  Unix Shell 程式設計
  高階 Unix
  Unix 有用參考
  Unix 有用資源
  精選閱讀

版權所有 © 2014 tutorialspoint



  首頁     參考資料     討論論壇     關於 TP  

wait4() - Unix,Linux 系統呼叫


previous next AddThis Social Bookmark Button

廣告

名稱

wait3, wait4 - 等待程序狀態改變,BSD 風格

概要

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

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

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

描述

wait3() 和 wait4() 系統呼叫類似於 waitpid(2),但額外返回指向 *rusage* 的結構中子程序的資源使用資訊。

除了使用 *rusage* 引數外,以下 wait3() 呼叫

wait3(status, options, rusage);

等效於

waitpid(-1, status, options);

同樣,以下

wait4() 呼叫

wait4(pid, status, options, rusage);

等效於

waitpid(pid, status, options);

換句話說,wait3() 等待任何子程序,而 wait4() 可用於選擇要等待的特定子程序或子程序。有關詳細資訊,請參閱 wait(2)。

如果 *rusage* 不是 NULL,則指向它的 *struct rusage* 將填充子程序的計費資訊。有關詳細資訊,請參閱 getrusage(2)。

返回值

waitpid(2) 相同。

錯誤

waitpid(2) 相同。

備註

如今不需要包含 *<sys/time.h>*,但這提高了可移植性。(實際上,*<sys/resource.h>* 定義了 *rusage* 結構,其欄位的型別為 *<sys/time.h>* 中定義的 *struct timeval*。)

只有在定義 _BSD_SOURCE 時,才能使用這些函式的原型。

符合標準

4.3BSD

參見



previous next Printer Friendly

廣告


  

廣告



廣告
© . All rights reserved.