How could my code compliled correctly without necessary headers?
- by ZhengZhiren
I use the functions fork(),exec()...
But how can this program compiled without including some extra headers(like sys/types.h, sys/wait.h).
I use ubuntu 10.04 with gcc version 4.4.3
#include <stdio.h>
#include <stdlib.h>
int main()
{
pid_t pid;
printf("before fork\n");
pid = fork();
if(pid == 0)
{
/*child*/
if(execvp("./cpuid", NULL))
{
printf("error\n");
exit(0);
}
}
else
{
if(wait(NULL) != -1)
{
printf("ok\n");
}
}
return 0;
}