forked from templates/base
		
	添加 src/fork.c
This commit is contained in:
		
							
								
								
									
										15
									
								
								src/fork.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								src/fork.c
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,15 @@
 | 
			
		||||
#include  <unistd.h>
 | 
			
		||||
#include  <stdio.h>
 | 
			
		||||
#include  <sys/types.h>
 | 
			
		||||
 | 
			
		||||
int main  () 
 | 
			
		||||
{
 | 
			
		||||
	pid_t  pid;
 | 
			
		||||
	pid=fork();
 | 
			
		||||
	if  (pid  <  0) 
 | 
			
		||||
		printf("error  in  fork!");
 | 
			
		||||
	else  if  (pid  ==  0)
 | 
			
		||||
		printf("i  am  the  child  process,  my  process  id  is  %d\n",getpid());
 | 
			
		||||
	else
 | 
			
		||||
		printf("i  am  the  parent  process,  my  process  id  is  %d\n",getpid()); 
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user