当前位置:网站首页>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 
边栏推荐
- GBASE现身说 “库” 北京金融科技产业联盟创新应用专委会专题培训
- "Software defines the world, open source builds the future" 2022 open atom global open source summit will open at the end of July
- Batch export excel zip using zipfile, openpyxl and flask
- C语言学习-18-makefile文件编写例子以及如何生成、调用动态库
- 【山大会议】使用TypeScript为项目进行重构
- C语言学生成绩排名系统
- 乱解码nlp
- 84. (cesium chapter) movement of cesium model on terrain
- Promoting compatibility and adaptation, enabling coordinated development of gbase may adaptation Express
- [single chip microcomputer] [make buzzer sound] know the buzzer and let it make the sound you want
猜你喜欢

【LeetCode】9、回文数

Jenkins automatically triggers compilation by checking code submissions
![[Shangshui Shuo series] day three - VIDEO](/img/42/0911fee2a36f6dda345a571a31acd5.png)
[Shangshui Shuo series] day three - VIDEO

C语言学习-18-makefile文件编写例子以及如何生成、调用动态库

小白操作Win10扩充C盘(把D盘内存分给C盘)亲测多次有效

Pymssql Module User Guide

Devsecops: best practices for ci/cd pipeline security

Binary search (integer binary)

Scala language learning-05-a comparison of the efficiency of recursion and tail recursion

C语言学习-17-函数作为参数传入函数
随机推荐
【山大会议】使用TypeScript为项目进行重构
对领域驱动设计DDD理解
标准化、最值归一化、均值归一化应用场景的进阶思考
宏源期货开户安全么?宏源期货公司可以降低手续费?
Rosbag使用命令
Rosbag使用命令
Rosbag use command
小程序开发----自定义有效期缓存
Exploration and practice of dewu app data simulation platform
String的模拟实现
【山大会议】私人聊天频道 WebRTC 工具类
Cve-2022-0847 (privilege lifting kernel vulnerability)
数字人民币可以买理财产品了!建行APP在试点地区上线服务专区,实测体验如何?
[译文] 弥合开源数据库和数据库业务之间的鸿沟
Hello, big guys. Error reporting when using MySQL CDC for the first time
做自媒体视频博主,必备的32个素材网站分享
Dear students, don't read the textbooks any more. Just read this one for the complexity of time
Scala language learning-06-differences between name passing parameters, value passing parameters and function passing parameters
Ask if you want to get the start of sqlserver_ Is there a good way for LSN?
Merge sort of sorting