linux - vfork 导致的进程问题
ringa_lee
ringa_lee 2017-04-17 13:06:44
0
1
667
int createproc();

int main()
{
    pid_t pid=createproc();
    printf("%d\n", pid);
    exit(0);
}

int createproc()
{
    pid_t pid;
    if(!(pid=vfork())) 
    {
        printf("child proc:%d\n", pid);
        return pid;
    }
    else return -1;
}

输出

child proc:0
0
child proc:0
Killed

为什么 vfork 之后,父子进程都走了“子进程”的分支?

所以想了解下 fork 和 vfork 的区别,什么原因导致了这样的结果。

ringa_lee
ringa_lee

ringa_lee

répondre à tous(1)
小葫芦

请参考:vfork 挂掉的一个问题
http://coolshell.cn/articles/12103.html

Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal
À propos de nous Clause de non-responsabilité Sitemap
Site Web PHP chinois:Formation PHP en ligne sur le bien-être public,Aidez les apprenants PHP à grandir rapidement!