1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
|
/*BINFMTC:
test that waitpid works expected way
*/
#include <sys/wait.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
int main()
{
pid_t pid;
int status;
switch(pid=fork())
{
case 0:
execl("/bin/cp", "/bin/cp", "-a", "/tmp/test", "/tmp/test2", NULL);
exit (0);
case -1:
perror("fork()");
exit (1);
default:
sleep(1);
if(-1==waitpid(pid, &status, 0))
{
perror("waitpid:cp");
exit(2);
}
printf("waitpid: %x\n", status);
exit (0);
}
}
|