about fork and execve system call

前端 未结 5 1773
难免孤独
难免孤独 2021-02-02 18:11

It is said that fork system call creates a clone of the calling process, and then (usually) the child process issues execve system call to change its i

5条回答
  •  旧时难觅i
    2021-02-02 18:55

    Each step is relatively simple.

    In Unix, your process has two parts -- a read-only memory area with the application code ("text") and the read-write memory area ("data").

    A fork clones the read-write area, leaving the text page alone. You now have two processes running the same code. They differ by a register value -- the return value from fork -- which separates parent from child.

    An exec replaces the text page, leaving the data page alone. There are many forms of exec, depending on how much environment information you're passing to it. See http://linux.die.net/man/3/exec for an additional list of variants.

提交回复
热议问题