标签:style blog class code ext c
#include <stdio.h> #include <unistd.h> int glob = 123; int main(void) { int x = 456; pid_t pid; if ((pid = fork()) < 0) return -1; else if (pid == 0) { // 子进程 glob++; x++; } else sleep(2); // 父进程休眠两秒钟 printf("pid = %d, glob = %d, x = %d\n", getpid(), glob, x); return 0; }
标签:style blog class code ext c
原文地址:http://blog.csdn.net/nestler/article/details/25535293