Linux process: child process
A program can start another program
When you run an application, the operating system gives it a place to work and keeps track of it while it is running. That running instance is called a process. A process can start another process to do a separate piece of work; the starter is called the parent, and the new one is its child. Linux gives each process a process ID, or PID, so it can be identified while it is alive.
Try this in Bash to watch a short-lived child process:
sleep 2 &
child=$!
ps -o pid,ppid,stat,cmd -p "$child"
wait "$child"
sleep 2 waits for two seconds. The ampersand asks Bash to run it in the background so the prompt returns. Bash stores the new job's PID in $!. ps prints that PID, its parent's PID (PPID), state, and command. wait pauses until the child ends and collects its exit status, a number that reports how it finished. PIDs can be reused after a process exits, so use the one shown for the process that is still running.
What Linux does when a child starts
Programs can ask Linux to create a child with the fork() system call. A system call is a request from a program to the kernel, the part of the operating system that manages processes and hardware. After fork(), both parent and child continue from the next instruction. The child receives 0 as the return value; the parent receives the child's PID. If creation fails, the parent receives an error instead.
The child begins with much of the parent's state, including memory and open file descriptors. Linux uses copy-on-write for memory: at first, parent and child can share the same physical memory pages, and Linux makes a separate copy when one process writes to a page. An open file descriptor is a program's handle for using an open file. After fork(), matching descriptors refer to the same open-file record. That means they share the file position and status flags. If both processes read through that descriptor, one read advances the position the other sees.
A child often calls an exec function next. exec replaces the running program's code and data with a different program while keeping the same PID. The shell uses process creation to start commands. It waits for a foreground command; adding & starts a background job. A pipeline may create several processes from one command line, and Bash tracks related jobs in process groups that also affect terminal input.
How a parent collects a child
A parent uses wait(), waitpid(), or a related API to learn how its child ended. If a child exits before the parent collects that result, Linux keeps a small record in the process table. This exited child is called a zombie. The parent reaps it by collecting its status; sending another termination signal cannot make the exited program run again.
If the parent exits first, an appropriate system process adopts the child. For troubleshooting, compare PID and PPID in ps or under /proc. If a service manager, the system component that starts and monitors background services, started the process, check the manager too: a service may have several workers, and its configuration may restart a process that exits.





