当前位置:网站首页>C language EXECL function
C language EXECL function
2022-07-01 03:08:00 【ma_ de_ hao_ mei_ le】
#include <unistd.h>
#include <fcntl.h>
#include <stdio.h>
#include <sys/types.h>
#include <string.h>
int main(int argc, char *argv[])
{
// execl function
// int execl(const char *pathname, const char *arg, ...
// pathname: The path of the file to execute ( Absolute path is recommended )
// The second parameter is a string , Is the parameter of the executable file specified in the first parameter ( It can be multiple parameters )
// The first parameter is the program name ( No dice )
// The second start is the parameters of the program
// The last parameter requires null end ( Used to inform execl End of parameter list —— sentry )
if (fork() > 0)
{
printf("I'm parent process: pid: %d\n", getpid());
sleep(1);
}
else
{
// Is currently a child process
// execl("/mnt/c/Users/x/Pictures/code/lesson14/2", "2", NULL);
execl("/bin/ps", "ps", "a", "u", "x", NULL);
printf("I'm child process: %d", getpid());
}
for (int i = 0; i < 3; i++)
{
printf("i=%d, pid: %d\n", i, getpid());
}
}
边栏推荐
- Mouse over effect 9
- JS to find duplicate elements in two arrays
- mybati sql 语句打印
- [exsi] transfer files between hosts
- 调试定位导航遇到的问题总结
- How to open a stock account? Also, is it safe to open an account online?
- POI exports excel and displays hierarchically according to parent-child nodes
- 单片机 MCU 固件打包脚本软件
- 几行事务代码,让我赔了16万
- Mouse over effect VI
猜你喜欢
MySQL knowledge points
EDLines: A real-time line segment detector with a false detection control翻译
[machine learning] vectorized computing -- a must on the way of machine learning
Completely solve the lost connection to MySQL server at 'reading initial communication packet
【Qt】添加第三方库的知识补充
【小程序项目开发--京东商城】uni-app之自定义搜索组件(上)
POI导出excel,按照父子节点进行分级显示
HTB-Lame
Huawei operator level router configuration example | configuration static VPLS example
[small program project development -- Jingdong Mall] the home page commodity floor of uni app
随机推荐
js中的原型和原型链
Mouse over effect 8
[linear DP] longest common subsequence
CX5120控制汇川IS620N伺服报错E15解决方案
Mouse over effect III
Druid监控统计数据源
[PR # 5 A] two way running (state pressure DP)
力扣-两数之和
Is it safe to open an account online in a small securities firm? Will my money be unsafe?
HTB-Lame
Share Creators萌芽人才培养计划来了!
Magnetic manometer and measurement of foreign coins
Gartner research: in China, the adoption of hybrid cloud has become the mainstream trend
实战 ELK 优雅管理服务器日志
Mouse over effect I
倍福TwinCAT3 Ads相关错误详细列表
Multithreaded printing
About the application of MySQL
Here comes the share creators budding talent training program!
Mouse over effect VI