当前位置:网站首页>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 
边栏推荐
- C语言学习-17-函数作为参数传入函数
- Scala language learning-05-a comparison of the efficiency of recursion and tail recursion
- (pytorch进阶之路二)word embedding 和 position embedding
- On the routing tree of gin
- Huawei cloud hcdez special session and Distributed Technology Summit: Huawei cloud distributed cloud native technology and Practice
- New design of databend SQL planner
- B树和B+树
- 跨界融合创意创新,助力提高文旅夜游影响力
- 二分查找(整数二分)
- 向量6(继承)
猜你喜欢

【VTK】模型旋转平移

快速玩转CI/CD图形化编排

Bridging the gap between open source databases and database services

CVE-2022-0847(提权内核漏洞)
![[译文] 弥合开源数据库和数据库业务之间的鸿沟](/img/e5/f89a8f3e2e9034f557ea3e76f37f81.jpg)
[译文] 弥合开源数据库和数据库业务之间的鸿沟
![[single chip microcomputer] [make buzzer sound] know the buzzer and let it make the sound you want](/img/cb/826b3591bafa62cc71826732eb32ef.png)
[single chip microcomputer] [make buzzer sound] know the buzzer and let it make the sound you want

B树和B+树

Simulation of vector

Sdvo:ldso+ semantics, direct French Slam (RAL 2022)
![[leetcode] 9. Palindromes](/img/58/1817b072949458f9652c144ac4ec0e.png)
[leetcode] 9. Palindromes
随机推荐
Advanced thinking on application scenarios of standardization, maximum normalization and mean normalization
二分查找(整数二分)
Rosbag use command
微信小程序头像挂件制作
Scala语言学习-04-函数作为参数传入函数-函数作为返回值
问一下想获取到sqlserver的start_lsn有好的办法吗?
得物App数据模拟平台的探索和实践
"Software defines the world, open source builds the future" 2022 open atom global open source summit will open at the end of July
"Forget to learn again" shell process control - 38. Introduction to while loop and until loop
Huawei cloud hcdez special session and Distributed Technology Summit: Huawei cloud distributed cloud native technology and Practice
Fast and accurate point cloud registration based on minimizing 3D NDT distance
又可以这样搞nlp(分类)
【newman】postman生成漂亮的测试报告
Meet webassembly again
【一起上水硕系列】Day Three - video
Wechat applet avatar pendant production
The bank card identification function of Huawei machine learning service enables bank card identification and binding with one click
On the routing tree of gin
模板特例化 template<>
宏源期货开户安全么?宏源期货公司可以降低手续费?