04进程基础
This commit is contained in:
parent
5a66fb4408
commit
a6fc27754b
26
Linux系统编程篇/04进程基础/execl.c
Normal file
26
Linux系统编程篇/04进程基础/execl.c
Normal file
@ -0,0 +1,26 @@
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int i = 0;
|
||||
pid_t pid;
|
||||
pid = fork();
|
||||
if (pid < 0)
|
||||
{
|
||||
printf("fork is error \n");
|
||||
return -1;
|
||||
}
|
||||
// 父进程
|
||||
if (pid > 0){
|
||||
printf("this is parent, parent pid is %d\n",getppid());
|
||||
}
|
||||
// 子进程
|
||||
if (pid == 0){
|
||||
printf("this is dhild, child pid is %d\n",getpid());
|
||||
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user