当前位置:网站首页>Program substitution function
Program substitution function
2022-06-22 15:58:00 【Stock god.】
Process replacement
If we want the child process to execute a “ New program ” Well ? You have to use process replacement technology . The process remains the same , Just replace the current code and data , It's called process replacement , Process substitution does not create a new process , Sub process id It hasn't changed . Just replaced the code and data .
execl()
path: The path of the target program to be executed
arg: Fill in the command and its parameters / Executable name
…: Variable parameter list , General filling NULL
Code example :
The function of this program replacement is : perform ls -a -l -n -i command .
Be careful :execl() You can not only use system commands , You can also use your own program , That is, fill in the path of the executable program written by yourself .
execv()
The use of this substitution function is similar to execl() almost , Only the incoming command is represented by an array 
Code example :
execlp()
This function does not need to take a path , But you need the file name of the executable you want to execute , Then take the order + Parameters 
Code example :
execvp()
This replacement function is the same as execlp be similar , Only the command and its parameters are represented by an array .
Code example :
execle()
The first three parameters are related to cxcl identical , The fourth parameter is passed to arg Corresponding executable program .
Code example :
myexe.c Source file : The function of this program is to print system environment variables 
Run this code : Print the environment variables of the system 
myload.c Source file : This code uses execle(). use myexe This program replaces this code , take env Data is passed to this program .
function myload.c: We found that myexe No longer print system variables , Instead, we print it and send it to myexe The variable of 
execve()
This replacement function is the same as excle be similar , Only the executable program name is represented by an array .
Code example :
Writing memory
I can't tell how to use these substitution functions , We can remember how to use these functions according to their names .
The function name has “l” , Means to write the command and its parameters
Yes “v”: Use an array to represent a command and its arguments
Yes “p”: It means no specific path is required
Yes "e": Indicates that you need to pass in your own environment variables 
边栏推荐
- [Shangshui Shuo series] day three - VIDEO
- [leetcode] 9. Palindromes
- ORB_ VI ideological framework
- Merge sort of sorting
- stack和queue的模拟实现
- 小白操作Win10扩充C盘(把D盘内存分给C盘)亲测多次有效
- HMS core news industry solution: let technology add humanistic temperature
- 程序替换函数
- Recommend several AI Intelligent Platforms
- Maze problem (BFS record path)
猜你喜欢
![[译文] 弥合开源数据库和数据库业务之间的鸿沟](/img/e5/f89a8f3e2e9034f557ea3e76f37f81.jpg)
[译文] 弥合开源数据库和数据库业务之间的鸿沟

关于 GIN 的路由树

MongoDB在腾讯零售优码中的应用

#进程地址空间

Development status of full color LED display

(pytorch advanced path 2) word embedding and position embedding
![[Newman] postman generates beautiful test reports](/img/5c/b95c1c475e69d69acad75215ea9565.png)
[Newman] postman generates beautiful test reports

Self inspection is recommended! The transaction caused by MySQL driver bug is not rolled back. Maybe you are facing this risk!

84. (cesium chapter) movement of cesium model on terrain

【LeetCode】9、回文数
随机推荐
对领域驱动设计DDD理解
普通人怎么在一年内赚到100万?
vector的模拟实现
标准化、最值归一化、均值归一化应用场景的进阶思考
Bridging the gap between open source databases and database services
How can ordinary people make 1million yuan a year?
Merge sort of sorting
快速排序quick_sort
信创研究:国产数据库聚焦信创市场,华为Gauss有望成为最强
高精度计算
C language learning -17- function is passed in as a parameter
问一下想获取到sqlserver的start_lsn有好的办法吗?
Advanced thinking on application scenarios of standardization, maximum normalization and mean normalization
Applet development - Custom expiration cache
Uni develops wechat applet to customize automatic camera detection (portrait + ID card)
关于 GIN 的路由树
【VTK】模型旋转平移
快速玩转CI/CD图形化编排
Discover the number of media new users can insert
Process address space