4,436
社区成员
发帖
与我相关
我的任务
分享
#include <stdio.h>
#include <unistd.h>
#include <sys/wait.h>
int main()
{
printf("old_tty_grp=%d\n", tcgetpgrp(0));
int pid;
if ((pid = fork()) == 0) {
while (1);
} else {
if (0 != setpgid(pid, pid)) return 1;
if (0 != tcsetpgrp(0, pid)) return 1;
printf("new_tty_grp=%d\n", tcgetpgrp(0));
int s, pid = waitpid(-1, &s, WCONTINUED | WUNTRACED);
printf("wait=%d, status=%x\n", pid, s);
}
return 0;