#include <unistd.h>;
#include <sys/types.h>;
main ()
{
pid_t pid;
pid=fork();
if (pid < 0)
printf("error in fork!");
else if (pid == 0)
printf("i am the child process, my process id is %dn",getpid());
else
printf("i am the parent process, my process id is %dn",getpid());
}
结果是 [root@localhost c]# ./a.out i am the child process, my process id is 4286 i am the parent ......
阅读全文