进程间通信-1
来源:互联网 发布:word转pdf软件 编辑:程序博客网 时间:2024/06/02 00:45
进程间通信-1
进程相关知识
启动新进程
system
定义
#include<stdlib.h>int system(const char* string);
作用
- system 调用一个shell来启动想要执行的程序
- system 可以放入后台执行
- 程序必须等待system函数启动的进程结束后才能继续
exec
定义
#include<unistd.h>int execl(const char* path,const char* arg0,....,(char*)0);int execlp(const char* file,const char* arg0,...,(char*)0);int execv(const char* path,char *const argv[]);int execvp(const char* file,char * const argv[]);
参数
- path:文件的绝对路径
- file:若文件在
PATH
中,则不需要提供绝对路径,提供文件名即可 - (char* )0:参数结尾的标志
作用
- exec会调用所给出来的程序,并替换当前进程,新进程的PID,PPID和nice值和原来完全一样
fork
定义
#include<sys/types.h>#include<unistd.h>pid_t fork(void);
作用
- 系统复制当前进程,子进程有自己的数据空间,环境和文件描述符
- 子进程返回的
pid_t
为0,原进程为子进程的值,由此可以区分父子进程
进程相关函数
getpid
定义
#include<unistd.h>pid_t getpid(void);
作用
- 获取当前进程的pid
waitpid
定义
#include<sys/types.h>#include<sys/wait.h>pid_t waitpid(pid_t pid,int * stat_loc,int options);
参数
- pid:等待的子进程的pid
- stat_loc:如果非空就将状态信息写入
- options:改变waitpid的行为
作用
- 等待子进程结束
0 0
- 进程间通信1
- 进程间通信1
- 进程间通信-1
- 进程间通信1
- 进程间通信1
- 进程间通信1
- 进程&进程间通信
- 进程间通信(1)进程及通信需求来源
- 进程间通信-1-160815
- Android进程间通信(1)
- Linux进程间通信 ---1
- 进程间通信方式1
- Linux进程间通信1
- Linux进程间通信1
- 进程间通信(1)
- 进程间的通信1
- Linux 进程间通信1
- 信号通信(进程间通信)
- Android Activity接收Service发送的广播
- 数据结构 顺序表的应用——学生信息统计
- [hdu5901 Count primes]Meisell-Lehmer求质数个数PI(X)
- Decress the bandwidth of the GPU
- 扣扣 、微信中的数字提醒
- 进程间通信-1
- HDU 5901 Count primes 2016年沈阳网络赛 (Lehmer素数计数)
- C#封装的实现
- Unable to authenticate: Fail to create new session
- 并行计算重要知识点与综述
- 漂亮的JQ“返回顶部” 按钮
- java 内存溢出 栈溢出的原因与排查方法
- per.ccz与png图片占用内存对比
- 计算客(无脑博士的试管们)