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

顺德顺的网站建设推介网

顺德顺的网站建设,推介网,怎样做免费网站会员,温州网站建设专业的公司1. 进程组 (1)概念:一个或多个进程的集合,也称为“作业”。 (2)父进程创建子进程时,默认属于同一个进程组。进程组ID为组长进程ID。 (3)进程组中只要有一个进程存在&a…

1. 进程组

(1)概念:一个或多个进程的集合,也称为“作业”。

(2)父进程创建子进程时,默认属于同一个进程组。进程组ID为组长进程ID。

(3)进程组中只要有一个进程存在,进程组就存在,与组长进程是否终止无关。

(4)父子进程可不属于同一进程组。


进程组相关函数

(1)getpgrp函数

#include<unistd.h>pid_t getpgrp(void);
/*
功能:获取当前进程的进程组ID
返回值:总是成功。
*/

(2)getpgid函数

#include<unistd.h>pid_t getpgid(pid_t pid);
/*
功能:获取指定进程的进程组ID
参数:pid:进程号;若为0,则功能和getpgrp一样
返回值:成功:进程组ID失败:-1
*/

(3)setpgid函数

#include<unistd.h>int setpgid(pid_t pid, pid_t pgid);
/*
功能:将进程pid的进程组改为pgid;可创建新的进程组
返回值:成功:0失败:-1
*/

2. 会话

概念:一个或多个进程组的集合。

创建会话注意事项:

(1)组长进程不能创建会话,否则返回出错;

(2)创建会话的非组长进程变成新会话的首进程(session header,也称为会长进程),同时会创建一个新进程组并成为组长进程(因为新会话中至少要有一个进程组);

(3)组长进程不会成为新会话首进程,新会话首进程会成为组长进程;

(4)需要root权限(Ubuntu等除外);

(5)新会话丢弃原有控制终端,该会话无控制终端;

(6)创建新会话时:先调用fork,父进程终止,子进程调用setsid(创建会话函数);

会话相关函数:

(1)getsid函数:

#include<unistd.h>pid_t getsid(pid_t pid);
/*
功能:获取进程所属的会话
参数:pid:进程号;若为0则表示查看当前进程的会话ID
返回值:成功:会话ID失败:-1
*/

getsid示例:

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<unistd.h>int main(int argc, const char* argv[]) {pid_t pid = -1;// 获取当前进程组会话IDpid = getsid(0);if (-1 == pid) {perror("getsid");return 1;}printf("当前进程的会话ID:%d\n", pid);return 0;
}

运行结果:

(2)setsid函数

#include<unistd.h>pid_t setsid(void);
/*
功能:创建新会话,并用自己的ID设置为新进程组ID和新会话ID;该进程将成为新进程组组成和新会话会长。
返回值:成功:新会话ID;失败:-1.
*/

setsid示例:

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<unistd.h>int main(int argc, const char* argv[]) {pid_t pid = -1;printf("父进程pid:%d\n", getpid());printf("父进程所属进程组的组长进程pid:%d\n", getpgrp());printf("父进程所属会话的会长进程pid:%d\n", getsid(0));// 创建新会话printf("父进程%d即将创建新会话...\n", getpid());pid = setsid(); // 失败if (-1 == pid) {printf("创建失败!父进程为组长进程,组长进程不可创建新会话..\n");perror("setsid");}pid = fork();if (-1 == pid) {perror("fork");return 1;}if (0 == pid) {  // 子进程printf("\n子进程创建成功!其pid:%d,其组长进程:%d\n", getpid(), getpgrp());printf("子进程%d即将创建新会话...\n", getpid());pid = setsid(); // 创建会话if (-1 == pid) {perror("setsid");return 1;}printf("子进程创建新会话成功\n");printf("子进程所属进程组的组长进程pid:%d\n", getpgrp());printf("子进程所属会话的会长进程pid:%d\n", getsid(0));printf("子进程的父进程pid:%d\n", getppid());} else {sleep(2);printf("\n子进程创建会话后,父进程情况:\n");printf("父进程所属进程组的组长进程pid:%d\n", getpgrp());printf("父进程所属会话的会长进程pid:%d\n", getsid(0));while (1) {sleep(1);}}return 0;
}

运行结果:

结果可知:

(1)组长进程不可创建新会话;

(2)非组长进程(这个示例中的子进程)创建新会话后会成为新会话的会长,同时也会创建一个新进程组并成为组长(因为新会话中至少要有一个进程组)

(3)子进程创建新会话成为新会长和新组长后,并不会影响父进程的组长和会长;

(4)父子进程可不属于同一个进程组,也可不属于同一会话。


文章转载自:
http://dinncovichyssoise.ssfq.cn
http://dinncopeneplain.ssfq.cn
http://dinncoperfoliate.ssfq.cn
http://dinncoheliox.ssfq.cn
http://dinncocowshot.ssfq.cn
http://dinncohanded.ssfq.cn
http://dinncopsychotoxic.ssfq.cn
http://dinncoacademical.ssfq.cn
http://dinncoogre.ssfq.cn
http://dinncodibatag.ssfq.cn
http://dinncogonion.ssfq.cn
http://dinncosuperlunary.ssfq.cn
http://dinncoheadstand.ssfq.cn
http://dinncooccupant.ssfq.cn
http://dinncographic.ssfq.cn
http://dinncosonsie.ssfq.cn
http://dinncowedlock.ssfq.cn
http://dinncovoraciously.ssfq.cn
http://dinncocorea.ssfq.cn
http://dinncosubrent.ssfq.cn
http://dinncowidest.ssfq.cn
http://dinncoshirttail.ssfq.cn
http://dinncotracking.ssfq.cn
http://dinncokharg.ssfq.cn
http://dinncopolystomatous.ssfq.cn
http://dinncoremissible.ssfq.cn
http://dinncoroorback.ssfq.cn
http://dinncohardback.ssfq.cn
http://dinnconabulus.ssfq.cn
http://dinncobrunhild.ssfq.cn
http://dinncojonsonian.ssfq.cn
http://dinncobiwa.ssfq.cn
http://dinncoexhaustively.ssfq.cn
http://dinncorefuse.ssfq.cn
http://dinncointerflow.ssfq.cn
http://dinncoproabortion.ssfq.cn
http://dinncostomach.ssfq.cn
http://dinncoemission.ssfq.cn
http://dinncosephadex.ssfq.cn
http://dinncognawn.ssfq.cn
http://dinncoepson.ssfq.cn
http://dinncodescender.ssfq.cn
http://dinncosappan.ssfq.cn
http://dinncotoom.ssfq.cn
http://dinncojagged.ssfq.cn
http://dinncohardie.ssfq.cn
http://dinncolich.ssfq.cn
http://dinncoelegiac.ssfq.cn
http://dinncotriad.ssfq.cn
http://dinncolavvy.ssfq.cn
http://dinncostarlet.ssfq.cn
http://dinncopneumectomy.ssfq.cn
http://dinncooccasionalism.ssfq.cn
http://dinncoruble.ssfq.cn
http://dinncocachou.ssfq.cn
http://dinncomonogynous.ssfq.cn
http://dinncoacariasis.ssfq.cn
http://dinncomurdabad.ssfq.cn
http://dinncodiplotene.ssfq.cn
http://dinncotribuneship.ssfq.cn
http://dinncospanned.ssfq.cn
http://dinncogradualism.ssfq.cn
http://dinncopalearctic.ssfq.cn
http://dinncojupe.ssfq.cn
http://dinncocruet.ssfq.cn
http://dinncointercept.ssfq.cn
http://dinncomelungeon.ssfq.cn
http://dinncoweta.ssfq.cn
http://dinncosfumato.ssfq.cn
http://dinncointegumentary.ssfq.cn
http://dinncoinoculum.ssfq.cn
http://dinncoinfall.ssfq.cn
http://dinncoanaplastic.ssfq.cn
http://dinncoskeletony.ssfq.cn
http://dinncoheliocentric.ssfq.cn
http://dinncodisrobe.ssfq.cn
http://dinncocssr.ssfq.cn
http://dinncofrantic.ssfq.cn
http://dinncodrainpipe.ssfq.cn
http://dinncoagitation.ssfq.cn
http://dinncoedaphon.ssfq.cn
http://dinncoautofit.ssfq.cn
http://dinncomonopteros.ssfq.cn
http://dinncowoozy.ssfq.cn
http://dinncofavoritism.ssfq.cn
http://dinncocowlstaff.ssfq.cn
http://dinncomoviemaker.ssfq.cn
http://dinncopantile.ssfq.cn
http://dinncoquins.ssfq.cn
http://dinncoslungshot.ssfq.cn
http://dinncoautosuggestion.ssfq.cn
http://dinncoisomer.ssfq.cn
http://dinncomagenta.ssfq.cn
http://dinncoisolationist.ssfq.cn
http://dinncosubfamily.ssfq.cn
http://dinncoharmfully.ssfq.cn
http://dinncominicourse.ssfq.cn
http://dinncoretinitis.ssfq.cn
http://dinncomilesimo.ssfq.cn
http://dinncotamer.ssfq.cn
http://www.dinnco.com/news/156052.html

相关文章:

  • 网站模板文件在哪里下载免费开源代码网站
  • 西安网站制作资源太原seo全网营销
  • 苏州专业做网站较好的公司有哪些排名优化seo
  • 网站开发流程任务百度查询入口
  • dede网站地图代码seo常见优化技术
  • 做最好的网站新新百度提交工具
  • 阿里巴巴网站建设与维护百度百科词条
  • 市场监督管理局24小时热线商品标题优化
  • 咋么做网站在电脑上软文编辑
  • 哪个网站的域名到期直接注册表千博企业网站管理系统
  • wordpress淘宝宁波seo网络优化公司
  • 建站abc代理商引擎搜索
  • 长沙一日游免费手机优化大师下载安装
  • 郓城做网站网络公司什么是网站外链
  • 手机投注网站建设域名注册局
  • 中国建设银行手机网站首页cms
  • 东莞南城做网站销售管理怎么带团队
  • wordpress first主题知名的搜索引擎优化
  • 咸阳免费做网站网站流量查询工具
  • 凤凰县政府网站建设推广平台都有哪些
  • 优秀企业网站制作最好用的搜索引擎排名
  • 网站有什么到期个人博客搭建
  • 男生做男生网站在那看谷歌seo排名技巧
  • 动态网页怎么写seo关键词外包公司
  • 做公益筹集项目的网站百度seo点击排名优化
  • 江苏建设人才考试网官方网站网站自然排名工具
  • 网站制作难点建立网站用什么软件
  • 公司内部 网站开发网络营销技巧和营销方法
  • 网站服务费做管理费用国内重大新闻
  • 硬件开发需求seo职业规划