#include <stdio.h>
#include <unistd.h>
int pipeline_child()
{
printf("child PPID:%d,PID:%d\n", getppid(), getpid());
while(1);
return 0;
}
int pipeline_father()
{
printf("father PPID:%d,PID:%d\n", getppid(), getpid());
while(1);
return 0;
}
int main()
{
pid_t pid = fork();
if (pid == -1) {
printf("failed process!\n");
return -1;
}
//子进程
if(pid == 0) {
printf("child process!\n");
printf("child PPID:%d,PID:%d\n", getppid(), getpid());
pipeline_child();
} else {
//父进程
sleep(1);
printf("father process!\n");
printf("father PPID:%d,PID:%d\n", getppid(), getpid());
pipeline_father();
}
return 0;
}
09-14
301
09-11
886