![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Can a child process return a specific value to a parent process ? | Ametis1970 | High Level Programming | 8 | 04-09-2008 08:22 PM |
| Child process is not getting started | Crab | High Level Programming | 5 | 09-17-2006 06:15 PM |
| gdb to child process | shriashishpatil | UNIX for Advanced & Expert Users | 4 | 12-12-2005 04:57 AM |
| KDM child process | larryase | UNIX for Dummies Questions & Answers | 6 | 01-24-2005 02:41 PM |
| Child Process PID | skannan | High Level Programming | 2 | 06-10-2002 04:54 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
hello every one,
i want to know more about creation of child process. UNDER WHAT CIRCUMSTANCES child process is created? WHAT ARE THE PREREQUISITES for a child process to be created? let us say we have a prog.c, prog.obj(compiled.c),.a\.out files. is any child PROCESS CREATED from the beginning to the execution of .a.out file in the above example please give me clear explanation thanks for your time |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
A child process is created by the fork() system call. So if prog.c correctly calls fork() it will generate a child process. It might indirectly call fork() by doing something like this:
system("date"); The system() function creates a child process which will exec() a shell. Then the shell will run the date command. A correct call to fork() can fail if there are too many processes already running or something like that. |
|
#3
|
|||
|
|||
|
child proc.
all child processes are created in two steps:
1. system creates the exact copy of parent process (by fork) 2. the code of the parent process is substituted within a code of the child process. as a consequence the child process inherits all the environment of the parent process (all the system variables , viewable with "env" command). This scheme is universal for all versions of unix/linux. Get "UNIX Essentials and UNIX Core" DVD course if you have questions like that. |
|
#4
|
||||
|
||||
|
Actually, that step 2 is describing what happens when an exec() system call is invoked. This is usually what happens. But exec() and fork() are different. Some programs fork() but then do not exec(). An example is an ftpd server not running under inetd (which is how we run pureFTPD). When it gets a connection, it forks and lets the child handle that session.
|
|
#5
|
|||
|
|||
|
ftpd
ftpd uses tcp and all tcp servers/deamons lunch new instances as request comes (disregarding of implementation). It does not exec not because it is exception but because it saves and extra operation as the next operation would be to load another instance of FTPd again, to save an extra step it does not exec.
|
|
#6
|
|||
|
|||
|
Advantage Of Child Process
when a parent process can do its job efficiently why do we need the over head to invoke some other process to perform the task on its behalf?
are there any system performance, advantages in invoking a child process? thanks for your replys in advance |
|
#7
|
|||
|
|||
|
here...
no, there's obviosly no system perfomance advantages sinse new process gets new resourses and take extra CPU time. Not all subsystems spawn new processes but only these that had been developed to. For example ftpd waits for connection it gets an connection and gives the way for a next connection. It does it by creating a new instance of itself while the old instance is occupied with an previos connection. If service is heavily depended on spawing there is limit in configuration for number of simultaniously working instances of one program. You can visit /etc/initd.conf or /etc/xinitd.conf and see the service "wait =no", or "respawn" for these services that will not wait for end of previos transaction to startnew one. By convension, all TCP services for example are "no wait". I learn with "UNIX Essentials and UNIX Core" DVD and with Emi Nemet book.
Hope it helps. Last edited by amro1; 03-20-2006 at 09:56 AM. |
|||
| Google The UNIX and Linux Forums |