当前位置:网站首页>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());
}
}
边栏推荐
- C#实现基于广度优先BFS求解无权图最短路径----完整程序展示
- Magnetic manometer and measurement of foreign coins
- MySQL knowledge points
- servlet【初识】
- Multithreaded printing
- Prototype and prototype chain in JS
- Cloud native annual technology inventory is released! Ride the wind and waves at the right time
- Codeforces Round #416 (Div. 2) C. Vladik and Memorable Trip
- 第03章_用户与权限管理
- Huawei operator level router configuration example | BGP VPLS configuration example
猜你喜欢

UE4 rendering pipeline learning notes

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

xxl-job使用指南

EtherCAT简介

别再说不会解决 “跨域“ 问题啦

Elk elegant management server log

世界上最好的学习法:费曼学习法

Voici le programme de formation des talents de SHARE Creators!

VMware vSphere 6.7 virtualization cloud management 12. Vcsa6.7 update vCenter server license

Redis高效点赞与取消功能
随机推荐
The 'mental (tiring) process' of building kubernetes/kubesphere environment with kubekey
SSH configuration password free login error: /usr/bin/ssh copy ID: error: no identities found solution
So easy 将程序部署到服务器
Metadata in NFT
【小程序项目开发 -- 京东商城】uni-app 商品分类页面(下)
Pytest -- plug-in writing
性能测试常见面试题
Saving images of different depths in opencv
# 使用 KubeKey 搭建 Kubernetes/KubeSphere 环境的'心路(累)历程'
XXL job User Guide
8 pits of redis distributed lock
CX5120控制汇川IS620N伺服报错E15解决方案
第03章_用戶與權限管理
xxl-job使用指南
【小程序项目开发 -- 京东商城】uni-app 商品分类页面(上)
VMware vSphere 6.7虚拟化云管理之12、VCSA6.7更新vCenter Server许可
通信协议——分类及其特征介绍
Servlet [first introduction]
Xception learning notes
【小程序项目开发-- 京东商城】uni-app之首页商品楼层