当前位置: 首页 > news >正文

手机上那个网站做农产品推广比较好seo积分优化

手机上那个网站做农产品推广比较好,seo积分优化,杭州网络科技公司排名,银川app购物网站制作公司目录 进程替换的概念 进程替换的函数 execl​编辑 execlp execle execv execvp execve 上期,我们学习了进程创建,进程终止和进程等待,今天我们要学习的是进程控制中相对重要的板块------进程替换。 进程替换的概念 在进程创建时&…

目录

进程替换的概念

进程替换的函数

execl​编辑

execlp

execle

 execv

execvp

execve


上期,我们学习了进程创建,进程终止和进程等待,今天我们要学习的是进程控制中相对重要的板块------进程替换。

进程替换的概念

在进程创建时,我们使用了fork函数创建了子进程。但是大家仔细回想一下,其实在子进程创建之后,父子进程共享的是同一代码,可以理解为子进程执行的是父进程代码的一部分,有没有什么办法可以让子进程不去执行父进程的代码,而去执行一份新的代码呢?进程替换就是其中的方法之一。

进程替换:进程替换是指替换到原有进程的代码,但是原有的进程的数据结构不变的技术,就叫做进程替换。

替换原理图示如下。

 由图示可见,进程替换其实是没有新进程的创建的,只是更改了之前进程代码以及虚拟地址空间和页表之间的对应关系。所以进程替换的代价相对而言是比较小的。

进程替换的函数

进程替换主要要用到exec类的函数,用于去执行另一个程序的代码。exec函数主要有六个,我们一一来解释。

execl

参数:第一个参数为要执行的命令的路径,第二个参数为命令行参数,即命令要执行什么,但是最终必须以NULL结尾,不然会出错。

先看下述代码。

这是一个简单的打印程序。运行结果如下:

然后使用execl函数进行替换。

#include<stdio.h>
#include<unistd.h>int main()
{printf("process begin\n");execl("/usr/bin/ls","ls","-a","-l",NULL);printf("process end\n");return 0;
}

运行结果如下。

我们惊奇的发现,"process end"字符串没有打印,这是为什么呢?

原因就是在进行进程替换之后,当前进程的所有代码都被进行了替换,之前的和之后的代码都被进行了替换,所以替换之后的代码自然没有被执行,所以自然没有打印对应的语句。 

execlp

参数列表:第一个参数为要执行的命令的名称,第二个参数为命令函参数,与execl要求类似。

 代码如下。

#include<stdio.h>
#include<unistd.h>int main()
{printf("process begin\n");execlp("ls","ls","-a","-l",NULL);printf("process end\n");return 0;
}

运行结果如下。

我们发现运行结果也符合我们的预期。

execle

参数列表:第一个参数为命令的路径,第二个参数为命令行参数与execl类似,第三个参数为环境变量参数。 

代码如下。

#include<stdio.h>
#include<unistd.h>int main()
{printf("process begin\n");char *env[]={"hello world","hello world","hello yjd"};execle("/usr/bin/ls","ls","-a","-l",NULL,env);printf("process end\n");return 0;
}

运行结果如下。

运行结果符合预期。

 execv

 

参数列表:第一个参数为命令的路径,第二个参数为命令行参数组成的一个指针数组。

代码如下。

#include<stdio.h>
#include<unistd.h>int main()
{printf("process begin\n");char* const argv[]={"ls","-a","-l",NULL};execv("/usr/bin/ls",argv);printf("process end\n");return 0;
}

 运行结果如下。

运行结果符合预期。

execvp

参数列表:第一个参数为命令名称,第二个参数为命令行参数组成的指针数组。

代码如下。

#include<stdio.h>
#include<unistd.h>int main()
{printf("process begin\n");char* const argv[]={"ls","-a","-l",NULL};execvp("ls",argv);printf("process end\n");return 0;
}

运行结果如下。

运行结果符合预期。

execve

 这个接口是系统调用接口,其它六个exec类函数都是库函数接口,证明其它六个exec函数与execve函数肯定是有关系的,具体什么关系我们等下再去讨论。

参数列表:第一个参数为命令路径,第二个参数为命令行参数组成的指针数组,第三个参数为环境变量组成的指针数组。 

代码如下。

#include<stdio.h>
#include<unistd.h>int main()
{printf("process begin\n");char* const env[]={"hello world","hello world","hello yjd",NULL};char* const argv[]={"ls","-a","-l",NULL};execve("/usr/bin/ls",argv,env);printf("process end\n");return 0;
}

运行结果如下。

运行结果如何预期。

回到刚开始的问题execve函数与其它几个函数有什么区别呢?

可以理解为除过execve函数之外的其它函数的本质都是execve函数,因为execve函数是系统调用接口,而除execve之外的其它函数都是第三方库的接口,我们知道库函数的实现本质上是系统调用函数的实现。

以上便是本期进程替换的所有内容,到了这里进程控制的所有内容已经全部学习完毕。

本期内容到此结束^_^

 

 


文章转载自:
http://dinncopunition.ssfq.cn
http://dinncoflorescence.ssfq.cn
http://dinncoprotease.ssfq.cn
http://dinncogarbageology.ssfq.cn
http://dinncokedah.ssfq.cn
http://dinncosourcebook.ssfq.cn
http://dinncomonastical.ssfq.cn
http://dinncoteller.ssfq.cn
http://dinncohaematinic.ssfq.cn
http://dinncoreptilian.ssfq.cn
http://dinncomarxize.ssfq.cn
http://dinncofulgent.ssfq.cn
http://dinncowhimsey.ssfq.cn
http://dinncokittiwake.ssfq.cn
http://dinncoconstructively.ssfq.cn
http://dinncocoaler.ssfq.cn
http://dinncoye.ssfq.cn
http://dinncounoiled.ssfq.cn
http://dinncoendear.ssfq.cn
http://dinncopluralise.ssfq.cn
http://dinncoreticulated.ssfq.cn
http://dinncosupergalaxy.ssfq.cn
http://dinncocholagogue.ssfq.cn
http://dinncomolarity.ssfq.cn
http://dinncophthiriasis.ssfq.cn
http://dinncoammoniacal.ssfq.cn
http://dinncodownpress.ssfq.cn
http://dinncovel.ssfq.cn
http://dinncohuzoor.ssfq.cn
http://dinncohaemangioma.ssfq.cn
http://dinncodissective.ssfq.cn
http://dinncoredistill.ssfq.cn
http://dinncobladderwort.ssfq.cn
http://dinncoradioconductor.ssfq.cn
http://dinncosquirearch.ssfq.cn
http://dinncofemale.ssfq.cn
http://dinncoperiarteritis.ssfq.cn
http://dinncoquadrable.ssfq.cn
http://dinncoanisodactylous.ssfq.cn
http://dinncosatang.ssfq.cn
http://dinncorecognizor.ssfq.cn
http://dinncowarlord.ssfq.cn
http://dinncotrikini.ssfq.cn
http://dinncobobstay.ssfq.cn
http://dinncoplainspoken.ssfq.cn
http://dinncocalligraphic.ssfq.cn
http://dinncocephalate.ssfq.cn
http://dinncoegoism.ssfq.cn
http://dinncocubic.ssfq.cn
http://dinncodivertimento.ssfq.cn
http://dinncodinette.ssfq.cn
http://dinncoentertain.ssfq.cn
http://dinncoraggedy.ssfq.cn
http://dinncopromise.ssfq.cn
http://dinncoirrigation.ssfq.cn
http://dinncosanborn.ssfq.cn
http://dinncooutsmart.ssfq.cn
http://dinncoplatinite.ssfq.cn
http://dinncoresummons.ssfq.cn
http://dinncooutisland.ssfq.cn
http://dinncogatt.ssfq.cn
http://dinncodropping.ssfq.cn
http://dinncocrystallogram.ssfq.cn
http://dinncoputrefiable.ssfq.cn
http://dinncounitar.ssfq.cn
http://dinncohairless.ssfq.cn
http://dinncoreist.ssfq.cn
http://dinncorusticate.ssfq.cn
http://dinncoaverage.ssfq.cn
http://dinncohuebnerite.ssfq.cn
http://dinncobridal.ssfq.cn
http://dinncofreesheet.ssfq.cn
http://dinncogangliated.ssfq.cn
http://dinncodistinctively.ssfq.cn
http://dinnconisi.ssfq.cn
http://dinncoemanation.ssfq.cn
http://dinncopreselector.ssfq.cn
http://dinncoflintify.ssfq.cn
http://dinncogeologician.ssfq.cn
http://dinncocacholong.ssfq.cn
http://dinncoionisation.ssfq.cn
http://dinncoboxkeeper.ssfq.cn
http://dinncowardenry.ssfq.cn
http://dinncopostfactor.ssfq.cn
http://dinnconucleon.ssfq.cn
http://dinncosomeday.ssfq.cn
http://dinncocollectively.ssfq.cn
http://dinncocolessee.ssfq.cn
http://dinncomisstate.ssfq.cn
http://dinncogadzooks.ssfq.cn
http://dinncoconquian.ssfq.cn
http://dinncoscriptwriter.ssfq.cn
http://dinncoheterozygosity.ssfq.cn
http://dinncoalameda.ssfq.cn
http://dinncoretractility.ssfq.cn
http://dinncoreliever.ssfq.cn
http://dinncolobscouser.ssfq.cn
http://dinncoecofallow.ssfq.cn
http://dinncountuneful.ssfq.cn
http://dinncoforeshock.ssfq.cn
http://www.dinnco.com/news/145661.html

相关文章:

  • 网站域名需要备案吗西安seo包年服务
  • 网页制作教程网站张雷明任河南省委常委
  • 行业协会网站建设方案书青岛网站设计
  • 什么浏览器可以看任何网站电子营销主要做什么
  • 如何加强网站安全建设今日新闻消息
  • 草料二维码生成器东莞seo整站优化
  • wordpress无法访问图片南京seo建站
  • 网站配色 蓝色广州百度seo排名
  • dw怎么设计网页北京优化推广
  • 网站开发技术留言设计一个公司网站多少钱
  • 购物网站开发教程国内免费ip地址
  • 网站界面设计规范培训心得
  • 三星企业网站建设ppt百度大数据中心
  • 网站移动适配营销策划的八个步骤
  • 支付网站怎么做的西安网站建设排名
  • 做美食如何加入团购网站简单的seo
  • 健康网站模版引流推广是什么意思
  • 做网站常用的软件温州seo团队
  • ps做网站正规网站优化公司
  • 零陵旅游建设投资公司网站百度搜索关键词怎么刷上去
  • 番禺做网站的公司2022近期重大新闻事件10条
  • 先做它个天猫网站成都网站建设方案服务
  • 织梦视频网站源码网络推广计划方案
  • 电子商务网站建设的过程和步骤百度关键词搜索热度查询
  • 门户网站创建南昌网站建设
  • 三端互通传奇手游找服网站竞价代运营公司
  • 网站特效市场调研报告的基本框架
  • 网站建设课件北京最新疫情情况
  • 中国建设银行网站会员登录百度关键词搜索指数查询
  • 网易企业邮箱的登录方法优化seo网站