Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix Now×
Skip to content
World desk2 min

Does a Child Inherit the Parent PID After exec?

A child gets its own PID from fork(). A successful exec replaces the child’s program image without changing that PID or its PPID.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

No. fork() gives the child a new PID; the child’s PPID is the PID of the process that called fork(). If the child then successfully calls execve(), it keeps its own PID and PPID while its program image is replaced.

What happens to the PIDs across fork and exec?

Let the process that calls fork() have PID P and PPID G. The identifiers change like this:

Point in sequence Running program PID PPID
Before fork() The original process P G
After fork() Parent P G
After fork() New child C, a new unique PID P
After the child successfully calls execve() The program loaded by exec C P

The child does not inherit the parent’s numeric PID. Linux and POSIX specify that the child has its own unique PID and that its PPID is the PID of the process that called fork() (Linux fork(2); POSIX fork()). Linux documents that both PID and PPID are preserved across execve() (credentials(7)).

Does exec create a new process?

No. execve() replaces the calling process’s program image; it does not create another process. The Linux execve(2) manual states that “there is no new process” and that the calling process’s PID remains unchanged. So when a child calls exec, it is still the same child process, now running a different program.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

People sometimes say that exec “starts a new process.” That is shorthand for starting a new program image in an existing process. The distinction matters when tracking process trees, PIDs, or a parent’s relationship to a child.

What changes when the child calls exec?

Exec replaces the program’s executable image, including its code, data, heap, and stack, with the image initialized for the target program. It does not preserve the old application memory as if the old program were continuing. At the same time, process identity and the parent-child relationship remain: the PID is still C and the PPID is still P.

Some process attributes have specific exec behavior rather than simply remaining untouched. The Linux execve(2) documentation describes exceptions including caught signal dispositions, the alternate signal stack, memory mappings, attached System V shared memory, POSIX shared-memory mappings, POSIX message-queue descriptors, named semaphores, and POSIX timers. Thus, “the same process” means the same process identity—not that every part of its state or memory remains identical.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

What if exec returns?

A successful execve() does not return to the old program: the old image has been replaced. If the call returns, it failed, so the old image is still running. The caller should inspect errno to determine the failure.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.