Date: Thu, 25 Apr 2002 16:30:07 -0400 From: "Kohler, Raymond J" <raymond.j.kohler@lmco.com> To: "'Bsd Neophyte'" <bsdneophyte@yahoo.com>, freebsd-questions@FreeBSD.ORG Subject: RE: what are parent and child processes all about? Message-ID: <B1B0DD19298CD41195A600508BF9067A04446A31@emss04m08.ems.lmco.com>
next in thread | raw e-mail | index | archive | help
-----Original Message----- From: Bsd Neophyte [mailto:bsdneophyte@yahoo.com] Sent: Thursday, April 25, 2002 4:16 PM To: freebsd-questions@FreeBSD.ORG Subject: what are parent and child processes all about? >"When a process is started, a duplicate of that process is created. This >new process is called the child and the process that created it is called >the parent. The child process then replaces the copy for the code the >parent process created with the code the child process is supposted to >execute." So you have a program running, the shell you type things at (the parent). It wants to run the program you typed. So what it does is to clone itself (that's the fork() system call), and the clone (the child) then transmutes itself into the program to be run (the exec() call). That's the code copy you're reading about here. That is, your shell can't run somthing else without destroying itself, so it forks another of itself and lets that destroy itself instead. >The last sentance confuses me the most. Actually the entire thing >confsues me. Why is a child process started anyways? Why does the parent >process spawn a child process in the first place? And what's all this >code copy stuff all about? A program can't "start another program". It can only "clone itself" or "transmute itself". So starting another program is a combination of these. >"While the command is executing, the shell waits until the child process >has completed. After is completes, the parent process terminates the >child process, and a prompt is displated, ready for a new command" >Why does this happen? I guess it goes back to my confusion about why the >child process is created in the first place. The shell just wants to wait for the first command to finish before doing another one. Otherwise things could get a bit muddled up (I'm oversimplifying here). -- Ray To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?B1B0DD19298CD41195A600508BF9067A04446A31>