myfork.c
来自「关于进程间通信的代码集锦2」· C语言 代码 · 共 25 行
C
25 行
#include <sys/types.h>#include <unistd.h>#include <stdio.h>#include <stdlib.h>int main(void){ pid_t result; result=fork(); switch(result) { case -1: printf("error!\n"); break; case 0: printf("In child process!\nThe return value is %d.\nMy pid is %d.\n",result,getpid()); break; default: printf("In parent process!\nThe return value is %d.\nMy pid is %d.\n",result,getpid()); break; } return 0;}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?