Chinaunix首页 | 论坛 | 博客
  • 博客访问: 15344426
  • 博文数量: 2005
  • 博客积分: 11986
  • 博客等级: 上将
  • 技术积分: 22535
  • 用 户 组: 普通用户
  • 注册时间: 2007-05-17 13:56
文章分类

全部博文(2005)

文章存档

2014年(2)

2013年(2)

2012年(16)

2011年(66)

2010年(368)

2009年(743)

2008年(491)

2007年(317)

分类: LINUX

2009-01-23 10:30:18

pid_t pid = fork();
if (pid == 0) {
        ...
        int result = execl(path, "adb", "fork-server", "server", NULL);
} else {
        // run a program in a new session
        setsid();//之前parent和child运行在同一个session里,而且parent是session头,所以,
        //所以作为session头的parent如果exit结束执行的话,那么会话session组中的所有进程将都被杀死,
        //所以执行setsid()之后,parent将重新获得一个新的会话session组id,child将仍持有原有的会话session组,
        //这时parent退出之后,将不会影响到child了[luther.gliethttp].
}
阅读(5217) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~