⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 evfork.c

📁 深圳英培特EduKit-III实验箱实验程序。一共有10多个
💻 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 + -