Linux进程
#include<stdio.h>#include<sys/types.h>#include<unistd.h>#include<stdlib.h>#include<signal.h>int main(){ pid_t child_pid; child_pid = fork(); signal(SIGCHLD, SIG_IGN); if (child_pid < 0) printf("Error occured on forking./n"); else if (child_pid == 0) { /*子进程工作*/ printf("child process PID:%d\n", (int)getpid()); exit(0); } else { /*父进程工作*/ printf("parent process PID:%d\n", (int)getpid()); sleep(30); exit(0); }}
?
?