2017-01-26 3 views
4

警告>関数 'wait'の暗示的宣言<を実行してもプログラムが正常に動作すると、なぜこの警告が表示されるのか理解したいと思いますか?事前に関数 'wait'の暗示的宣言

おかげ

編集:

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

をプログラムの先頭に取得するために:私は、ライブラリを追加するのを忘れは、あなたが配置する必要があり

#include <stdio.h> 
#include <stdlib.h> 
#include <sys/types.h> 
#include <unistd.h> 


void create (char* program, char** arg_list) 
{ 
    /* put your code here */ 
    pid_t childPid; 
    int status; 

    if((childPid = fork()) < 0){ 
    printf("Failed to fork() --- exiting...\n"); 
    exit(1); 
    } 
    else if (childPid == 0){ // --- inside the child process 
    if(execvp(program, arg_list) < 0){ // Failed to run the command 
     printf("*** Failed to exec %s\n", program); 
     exit(1); 
    } 
    } 
    else{ // --- parent process 
    while(wait(&status) != childPid) 
     printf("...\n"); 
    } 
} 
+0

あなたは機能のために '#のinclude'ラインを逃しています。 – Barmar

答えて

14

に示されている:

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

ありがとう、私は待機ライブラリを忘れてしまった – AyeJay

2

を含ま関数の宣言。

これはおそらく、wait(2)のヘッダーが欠落しているman page

関連する問題