linux - Fork()-ing a new process -


fork()-ing process end calling do_fork() inside kernel, making exact copy of itself. when read through books, says child of fork call exec create new process.

example:

ls command on shell, create way.

   sh(parent)        |    sh(child)        |    ls(new process) 

but, not able understand how & exec*() called? because, can see shell(child) created in fork. but, when , new process created/executed?

you have exec() if want new program running in 1 of processes (usually child not absolutely necessary). in specific case shell executes ls, shell first forks, child process execs. it's important realise 2 distinct operations.

all fork() give 2 (nearly) identical processes , can use return code fork() decide if you're parent (you positive pid of child, or -1 if fork() failed) or child (you 0).

see this answer description on how fork() , exec() work (under your control) , how can used without each other.

similar do_fork(), exec stuff boils down calls do_execve, located in exec.c.


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -