码迷,mamicode.com
首页 > 系统相关 > 详细

Linux : Forks()

时间:2020-06-20 19:41:54      阅读:64      评论:0      收藏:0      [点我收藏+]

标签:lazy   loading   inf   creat   image   wan   load   created   fork   

/* 
 *  fork_test.c 
 *  version 1 
 *  Created on: 2010-5-29 
 *      Author: wangth 
 */  
#include <unistd.h>  
#include <stdio.h>   
int main ()   
{   
    pid_t fpid;
    int count=0;  
    fpid=fork();   
    if (fpid < 0)   
        printf("error in fork!");   
    else if (fpid == 0) {  
        printf("i am the child process, my process id is %d/n",getpid());   
        printf("I‘m the father‘s son/n");
        count++;  
    }  
    else {  
        printf("i am the parent process, my process id is %d/n",getpid());   
        printf("I am the father of the child/n");  
        count++;  
    }  
    printf("Conclusion: %d/n",count);  
    return 0;  
} 

技术图片

Linux : Forks()

标签:lazy   loading   inf   creat   image   wan   load   created   fork   

原文地址:https://www.cnblogs.com/enomothem/p/13169383.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!