It’s the last day of 2024 and what can be better than learning some C? Today, we take a deep dive into the program calling functionality in C. Let’s start with the beginning! Every program turns into a process during execution. In C, process interaction happens with two system calls, the fork()
syscall and the exec()
syscall (exec()
is not a single syscall but a family of syscalls).
fork() and exec()
When we fork()
a process, we create a child process which contains (almost) the same information as the parent (the forking process). After we successfully fork a process, the Process ID (PID) of the child is returned to the parent and a PID of 0 is returned to the child.