The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


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 !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Parent child Relation !! using awk/sed ??? varungupta UNIX for Advanced & Expert Users 0 01-29-2008 10:24 AM
exiting a child without stopping the parent madpenguin Shell Programming and Scripting 5 09-19-2007 07:45 PM
Parent/Child Processes yoi2hot4ya Shell Programming and Scripting 2 05-31-2006 10:27 AM
kill parent and child larry UNIX for Dummies Questions & Answers 4 01-11-2003 08:18 PM
How hard can it be? ps child/parent velde046 Filesystems, Disks and Memory 2 05-25-2002 01:36 PM

Closed Thread
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-25-2002
Registered User
 

Join Date: Sep 2001
Posts: 114
what are parent and child processes all about?

I don't follow what these are...

this is what my text says...

"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."

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?

The next paragraph states...

"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.
Forum Sponsor
  #2 (permalink)  
Old 04-26-2002
Kelam_Magnus's Avatar
Unix does a body good.
 

Join Date: Aug 2001
Location: DFW McKinney, TX,
Posts: 1,069
Good example.

When you use a command like grep or find, they kick off subprocesses (children processes) that actually do the work.

EXAMPLE #1
The parent ( the command that you typed.) "find . -name somefile -print " kicks off subprocesses that actually go out and search for the file that you specified. When they are done they report back to the find command.

EXAMPLE #2
Using grep if you are trying to do something like matching a pattern(s) in a file to print out the lines.

cat filename|grep patterna

This command will actually spawn 2 processes. The cat command, the parent, and the grep command, the child. When the child (grep) finishes it returns to the parent (cat) with the result.

Example #3
Do a ps -aef |grep sh" to find your telnet session. Find your login and do a ps -aef |grep on that PID. All of your commands are technically children of your telnet session as you will see.
__________________
My brain is your brain
Google UNIX.COM
Closed Thread

Thread Tools
Display Modes




All times are GMT -7. The time now is 05:23 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0