Skip to content

Instantly share code, notes, and snippets.

@cho0h5
Created December 18, 2021 03:29
Show Gist options
  • Save cho0h5/6d35e4d55cccfe58a966a7158d9b9b92 to your computer and use it in GitHub Desktop.
Save cho0h5/6d35e4d55cccfe58a966a7158d9b9b92 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <unistd.h>
int main() {
printf("PID: %d\n", getpid());
pid_t pid = fork();
printf("fork ret: %d\n", pid);
return 0;
}
// PID: 189265
// fork ret: 189266
// fork ret: 0
// fork()
// 부모 프로세스에서는 자식 프로세스의 pid를 반환하고
// 자식 프로세스에서는 0을 반환
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment