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


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

版權所有 © 2014 tutorialspoint



  首頁     參考     討論論壇     關於 TP  

wait3() - 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

廣告


  

廣告



廣告