相关疑难解决方法(0)

父进程死亡时的新父进程

在 UNIX 中,当父进程消失时,我认为所有子进程都将 init 重置为其父进程。这不是一直正确吗?有任何例外吗?

process exit init

27
推荐指数
3
解决办法
2万
查看次数

输出中出现意外的父进程 ID

我的代码正在分叉一个进程并打印每个进程的 PID 和 PPID。我期待孩子的 PPID 与父母的 PID 相同,但事实并非如此。

我正在使用 Ubuntu 14.04。

#include <stdio.h>
#include <sys/wait.h>

int main(){
    int pid;
    pid = fork();
    if(pid==0){
        printf("\nI am the child and my parent id is %d and my id %d\n", getppid(), getpid());
    }
    else
        printf("\nI am the parent and my pid is %d and my parent id is %d\n", getpid(), getppid());

    return 0;
}
Run Code Online (Sandbox Code Playgroud)

这是我得到的输出:

I am the parent and my pid is 29229 and my parent id is 27087
I am the …
Run Code Online (Sandbox Code Playgroud)

linux ubuntu system-calls fork

2
推荐指数
1
解决办法
543
查看次数

关于流程生命周期的问题

我已经设法对流程生命周期中的系统调用wait(2)_exit(2)系统调用进行了质疑。

我关于wait(2)系统调用的问题是......父进程是否将它发布给内核?还是内核将其发布给父进程?并且是_exit(2)从子进程到父进程的 [ ] 系统调用问题吗?还是子进程_exit(2)向内核发出 [ ] ?

我尝试谷歌搜索并观看 youtube 视频以获得答案......但我从未看到任何特定于此的东西。

process system-calls exit wait

2
推荐指数
1
解决办法
166
查看次数

标签 统计

exit ×2

process ×2

system-calls ×2

fork ×1

init ×1

linux ×1

ubuntu ×1

wait ×1