Fork and exit process
来源:互联网 发布:mac lovelorn试色 编辑:程序博客网 时间:2024/06/02 22:22
Int fork():
One process can create another process that is child process through fork(). fork() is called once but return twice. The different of twice return is returned 0 by child process but child ID by parent process.
The child process is the copy of the parent process, it gets the copy of the parent such as data space,stack,heap resource. So, the child process has the copy of the space, it can't share these resource with parent, only share the code segment.
The usage of the fork():
int pid = fork():
if(pid == 0)
printf("This is child process.")
else if(pid > 0)
printf("This is parent process");
//you can get the pid from the parent process.
If you want to launch a process in another process, you can create a child process to do it through fork().
Exit(int status);
If you exit you child process, the parent process can get the status and child process ID(This is a good way to get the child process ID when the child process exit.)
The following code is the example of exit() and fork()
The important Point: exit(status)--the status reserve the last 8bit int( status & 0377)
(If you status is greater than 255, you don't get the correct status code in parent process.)
- Fork and exit process
- fork vfork exit _exit
- fork a process
- linux process fork related
- wait && child process && fork
- fork与vfork,exit与—exit
- fork vfork exit _exit区别
- fork, vfork以及return, exit
- System.exit和Process.killProcess
- fork,Process,Pool的比较
- exit(0) and exit(1)
- Android System.exit(code) and android.os.Process.killProcess(pid)或者发生RunTimeException 导致应用重启
- Android System.exit(code) and android.os.Process.killProcess(pid)或者发生RunTimeException 导致应用重启
- zombie process and orphan process
- zombie process and orphan process
- 进程编程—fork,getpid,exit,_exit
- 进程编程—fork,getpid,exit,_exit
- 进程编程—fork,getpid,exit
- 第十三节--android常用操作命令
- 对数作为基本的分析工具
- linux loop device介绍
- ACM中Java的应用
- 使用json.net 组件 生成JSON字符串,自定义日期格式
- Fork and exit process
- jQuery.Easy-UI 中控制tabs 打开的数量
- java 静态导入
- read和recv等函数的区别
- XP修改系统时间代码
- Java中Object类的equals()和hashCode()方法深入解析
- WCF - 泛型
- ORACLE函数大全
- 中长期规划---螺旋式上升方式修改完善职业之路