当前位置:网站首页>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());
}
}
边栏推荐
- PCB defect detection based on OpenCV and image subtraction
- 彻底解决Lost connection to MySQL server at ‘reading initial communication packet
- 如何校验两个文件内容是否相同
- Golang多图生成gif
- js中的原型和原型链
- [applet project development -- JD mall] uni app commodity classification page (first)
- Introduction and installation of Solr
- Mouse over effect 10
- EtherCAT原理概述
- servlet【初识】
猜你喜欢

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

Cloud native annual technology inventory is released! Ride the wind and waves at the right time
![[applet project development -- JD mall] uni app commodity classification page (Part 2)](/img/f3/752f41f5b5cc16c8a71498ea9cabb5.png)
[applet project development -- JD mall] uni app commodity classification page (Part 2)

Huawei operator level router configuration example | configuration optionA mode cross domain LDP VPLS example

【EXSI】主机间传输文件

Communication protocol -- Classification and characteristics Introduction

Latest interface automation interview questions

lavaweb【初识后续问题的解决】

Mysql知识点

【机器学习】向量化计算 -- 机器学习路上必经路
随机推荐
Voici le programme de formation des talents de SHARE Creators!
Mysql知识点
C#实现基于广度优先BFS求解无权图最短路径----完整程序展示
How to determine the progress bar loaded in the loading interface when opening the game
Chapitre 03 Bar _ Gestion des utilisateurs et des droits
# 使用 KubeKey 搭建 Kubernetes/KubeSphere 环境的'心路(累)历程'
Best used trust automation script (shell)
最好用的信任关系自动化脚本(shell)
Multithreaded printing
Add / delete / modify query summary insert/create/put/add/save/post, delete/drop/remove, update/modify/change, select/get/list/find
Pytest -- plug-in writing
Common interview questions for performance test
Mybati SQL statement printing
Huawei operator level router configuration example | BGP VPLS configuration example
别再说不会解决 “跨域“ 问题啦
C#实现图的深度优先遍历--非递归代码
STM32 - DS18B20 temperature sampling of first-line protocol
Servlet [first introduction]
【小程序项目开发-- 京东商城】uni-app之首页商品楼层
Const and the secret of pointers