We help IT Professionals succeed at work.
Get Started

Questions About fork() & waitpid() .... C/C++ Socket Programming in Linux and Unix

F-J-K
F-J-K asked
on
3,226 Views
Last Modified: 2013-12-23
"Waitpid() - In modern computer operating systems, a process (or task) may wait on another process to complete its execution. In most systems, a parent process can create an independently executing child process. The parent process may then issue a wait system call, which suspends the execution of the parent(its own) process while the child executes. When the child process terminates, it returns an exit status to the operating system, which is then returned to the waiting parent process. The parent process then resumes execution. The exit status returned by a child process typically indicates whether the process terminated normally or abnormally."

>>quote "The parent process then resumes execution."

1. What does it resume exactly? What kind of execuion?

"every process is created when another process executes the fork system call. The process that invoked fork is the parent process and the newly-created process is the child process. Every process has one parent process, but can have many child processes. The kernel identifies each process by its process identifier (PID). Process 0 is a special process that is created when the system boots; after forking a child process (process 1), process 0 becomes the swapper process & process 1, known as init, is the ancestor of every other process in the system."

>>quote "The process that invoked fork is the parent process and the newly-created process is the child process. Every process has one parent process, but can have many child processes. "

2. The process that invoked fork is the parent process. Does this mean
a child process and can create a new process?

Every process has one parent process. Parent process always has many child processes. and every child process can create another new child process which makes the first child process becomes a parent to the new child process, and in the same time it is considered a child process to its parent process. It is like a parent creates a child and child creates a new child! so the new child process has a parent of a child process who got another parent. It goes like a chain. Thats how i understand it. Is this right?

If yes, then

a. when the parent process will get a chance to create several child process who do not have another child process under them?

If no,
b. can you fix it for me please?




Comment
Watch Question
CERTIFIED EXPERT
Top Expert 2006
Commented:
This problem has been solved!
Unlock 1 Answer and 6 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE