23,120
社区成员
发帖
与我相关
我的任务
分享
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
int
main(int argc, char *argv[])
{
int status;
pid_t pid;
pid = fork();
if (0 == pid) {
exit(2);
} else {
wait(&status);
printf("status = %d\n", status);
if (WIFEXITED(status))
printf("WEXITSTATUS(status)=%d\n", WEXITSTATUS(status));
}
return 0;