当前位置:网站首页>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());
}
}
边栏推荐
- How to open a stock account? Also, is it safe to open an account online?
- 倍福TwinCAT3 Ads相关错误详细列表
- Mouse over effect 10
- Restcloud ETL WebService data synchronization to local
- Catch 222222
- Druid monitoring statistics source
- MySQL index --01--- design principle of index
- Mouse over effect 8
- UE4 rendering pipeline learning notes
- Mnasnet learning notes
猜你喜欢

最好用的信任关系自动化脚本(shell)

限流组件设计实战

How to verify whether the contents of two files are the same

The best learning method in the world: Feynman learning method

手把手带你了解一块电路板,从设计到制作(干货)

Huawei operator level router configuration example | BGP VPLS and LDP VPLS interworking example

Restcloud ETL data realizes incremental data synchronization through timestamp

Communication protocol -- Classification and characteristics Introduction

xxl-job使用指南

Voici le programme de formation des talents de SHARE Creators!
随机推荐
伺服第二编码器数值链接到倍福PLC的NC虚拟轴做显示
About the application of MySQL
Chapter 03_ User and authority management
ssh配置免密登录时报错:/usr/bin/ssh-copy-id: ERROR: No identities found 解决方法
Introduction and basic knowledge of machine learning
Densenet network paper learning notes
咱就是说 随便整几千个表情包为我所用一下
POI exports excel and displays hierarchically according to parent-child nodes
A few lines of transaction codes cost me 160000 yuan
调试定位导航遇到的问题总结
Multithreaded printing
Is it safe to open a stock account? Shanghai stock account opening procedures.
lavaweb【初识后续问题的解决】
第03章_用户与权限管理
How to verify whether the contents of two files are the same
Huawei operator level router configuration example | configuration optionA mode cross domain LDP VPLS example
ctfshow爆破wp
EtherCAT原理概述
[linear DP] shortest editing distance
php批量excel转word