📄 evfork.c
字号:
/*********************************************************************
* File: evfork.c
* Author: Embest J.Zhao 2005.2.17
* Desc: processes
* History:
*********************************************************************/
#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
main()
{
int pid;
//creat the child process.
pid=vfork();
//execute process according to the pid returned.
if (pid < 0)
//creat failed.
printf("error in fork!\n");
else if (pid == 0)
//return 0 ,exec the child.
printf("i am the child process, my process id is %d\n",getpid());
else
{
//return the child pid,exec the parent.
printf("i am the parent process, my process id is %d\n",getpid());
exit(0);
}
printf("end pid is %d\n",getpid());
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -