Created
December 18, 2016 13:19
-
-
Save bongbongco/4f2b24cc82ca23643c4d1cf0bff79f0d to your computer and use it in GitHub Desktop.
vfork - TGID, PID
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <sys/types.h> | |
#include <unistd.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <linux/unistd.h> | |
int main(void) | |
{ | |
int pid; | |
printf("before vfork \n \n"); | |
if((pid=vfork()) < 0 ) { | |
perror("fork error \n"); | |
exit(-2); | |
} else if (pid == 0) { | |
printf("TGID(%d), PID(%d) : Child \n", getpid(), syscall(__NR_gettid)); | |
_exit(0); | |
} else { | |
printf("TGID(%d), PID(%d) : Parent \n", getpid(), syscall(__NR_gettid)); | |
} | |
printf("after vfork \n \n"); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment