Top "Fork" questions

The `fork()` function is the Unix/Linux/POSIX way of creating a new process by duplicating the calling process.

How to share memory between processes created by fork()?

In fork child, if we modify a global variable, it will not get changed in the main program. Is there …

c fork
What exactly does fork return?

On success, the PID of the child process is returned in the parent’s thread of execution, and a 0 is …

c linux fork
how to kill child of fork?

I have the following code which create a child fork. And I want to kill the child before it finish …

c fork
Zombie process vs Orphan process

A Zombie is created when a parent process does not use the wait system call after a child dies to …

c unix fork zombie-process
How to exit a child process and return its status from execvp()?

In my simple custom shell I'm reading commands from the standard input and execute them with execvp(). Before this, I …

c exec fork exit
How do I change which GitHub project I forked from?

I forked a project, made some changes, and got a pull request accepted. But now, the project I forked moved …

git github fork
What is the purpose of fork()?

In many programs and man pages of Linux, I have seen code using fork(). Why do we need to use …

c unix posix fork
how to exit a child process - _exit() vs. exit

Consider this code snippet: pid_t cpid = fork(); if (cpid == -1) { perror("fork"); exit(EXIT_FAILURE); } if (cpid == 0) { // in child …

c process fork
getpid and getppid return two different values

When I run the code below #include <stdio.h> #include <sys/types.h> //int i=0; int …

c fork pid
How to kill all subprocesses of shell?

I'm writing a bash script, which does several things. In the beginning it starts several monitor scripts, each of them …

bash shell process fork kill