Question About Multi-Processed Applications... fork()

Thread Tools Search this Thread
Top Forums Programming Question About Multi-Processed Applications... fork()
# 1  
Old 11-19-2008
Question About Multi-Processed Applications... fork()

Assume we have an application built on *nix that uses fork()...then the processes procedure is going to act as follow:

X is considered a parent process (first click on application)
Y is considered a child process of X (second click on application)
Z is considered a child process of Y (third click on application)

If Y terminates, signal is sent to X to let X knows that Y is exited...
If Z terminates, signal is sent to Y (parent process of Z) to let Y knows that Z is exited...

1. Right?

2. If yes, then why Z exits status is not returned to X? Why not all exit status get returned to the very first parent process?
# 2  
Old 11-19-2008
The very first parent process is not your program, it's init, the startup program UNIX runs on boot to create all other processses. I doubt you want your signals to end up there. Smilie Though if the parent dies before the child does, that is where the child's signal will end up.
# 3  
Old 11-19-2008
ha ok, i see. orphan child signal will end up to init....

so it goes like


X is parent of Y. X is child of init().....

So lets say i opened a browser in *nix. This browser is multi-process.
First browser opened (X) is going to be a child on init()
Second browser (Y) opened, is going to be a child of (X).
X will take care of Y. If X dies, init() takes care of Y..

I hope this is right. I would like somebody to confirm!

Many THANKS!!!
# 4  
Old 11-19-2008
If you open two browsers, they'd be two children of the same parent, not one as the parent of the other.

There's also more layers than init -> user application -> children, though that's enough for examples. Init creates the window server which creates the login manager which creates everything you run; or for a shell, init creates the login shell which creates your processes.
# 5  
Old 11-19-2008
I see...

I made my assumption based on this quote:

"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. Parent process does not *always* have many child process only when it forks them."

Thats why i thought second browser is a child of the first browser...
# 6  
Old 11-19-2008
That paragraph isn't written very clearly. If a process created a process, the old process is that new process' parent, it's that simple.
# 7  
Old 11-19-2008
alright....thanks! i got it
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

Linux fork, execv, wait question

Hi All, I have a program for class that needs to do the following: 1. Print the directory entries from the current directory using ncurses 2. Provide a prompt next to each directory entry and allow the user to enter commands that may or may not be about the file 3. Execute those commands in... (1 Reply)
Discussion started by: afulldevnull
1 Replies

2. Programming

question about fork

i'm experimenting fork function and i found this code #include <stdio.h> #include <sys/stat.h> #include <sys/types.h> #include <wait.h> #include <fcntl.h> #include <unistd.h> int main(void) { int fd; pid_t p; p = fork(); fork(); if (p>0) { fork();} fork(); fork();... (6 Replies)
Discussion started by: blob84
6 Replies

3. Programming

Newbie question on exec,fork, wait,pipe C

Hello everybody.I want to make clear that i am not going to ask from anybody to build my asignement but i have a big problem. I can't seem to find anywhere ONE good example on C about what i am trying to do:wall:.I think it is simple. All i ask is one example, even a link is fine. So, i want to... (1 Reply)
Discussion started by: Cuervo
1 Replies

4. Programming

multiple fork() question

I writing a program that forks three times but only on the parent process. The three children processes then produces output in order. 1, 2, 3. I am confused on how to do this. I have tried multiple if and else if statements but the output does not come out right. How should I go about doing this? (1 Reply)
Discussion started by: TWhitt24
1 Replies

5. Programming

Beginners question about fork

Hi everyone: I'm developing a dynamic library for notifications, this library is used for a daemon that i've programmed, when something goes wrong the library should send an email to an administrator, but since sending an email is a non-vital process then it can fail (it should work as an... (4 Replies)
Discussion started by: edgarvm
4 Replies

6. High Performance Computing

What is it about OpenMosix that supports multi-process applications?

I read that 'Any single program that can run as multiple processes can benefit from OpenMosix: "The GIMP" photo editor and the "kandel" fractal generator are known to do this. Are there other load-balancing clusters that do support multi-process applications? (1 Reply)
Discussion started by: Advice Pro
1 Replies

7. Programming

A small question about fork()

Hello experts, I am using fork() in my code but I am confused which output comes first child or parent? I did the following code .My book shows parent first but my linux shows child first.Can anyone tell me why? #include <stdio.h> int main(){ int pid; printf("I am original process with pid... (5 Replies)
Discussion started by: mlhazan
5 Replies

8. UNIX for Advanced & Expert Users

one question to critical workloads and applications functions

hi everybody, what mission critical workloads and applications functions can run on the UNIX operating system? best regards (5 Replies)
Discussion started by: styfo
5 Replies

9. Programming

Multi threading using fork

Hi, I have written a code which will run a set of process using fork. I want to know from You how can i start another job when one of my job in my loop is completed My code is #include<stdio.h> #include<ctype.h> main() { int pid,cid; ChildProcess(); ... (1 Reply)
Discussion started by: sureshraju_ma
1 Replies

10. Programming

simple fork question

When executing this simple program: #include <unistd.h> void main() { int f; printf("\n Parent procces ID=%d\n",getpid()); f=fork(); if(f==0) { printf("\n Child process ID=%d father=%d\n",getpid(),getppid()); } ... (2 Replies)
Discussion started by: bb666
2 Replies
Login or Register to Ask a Question

Featured Tech Videos