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?
10 More Discussions You Might Find Interesting
1. Programming
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
2. Programming
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
3. UNIX for Advanced & Expert Users
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
4. Programming
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
5. High Performance Computing
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
6. Programming
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
7. Programming
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
8. Programming
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
9. Programming
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
10. Programming
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
EXIT(2) BSD System Calls Manual EXIT(2)
NAME
_exit -- terminate the calling process
SYNOPSIS
#include <unistd.h>
void
_exit(int status);
DESCRIPTION
The _exit() function terminates a process, with the following consequences:
o All of the descriptors that were open in the calling process are closed. This may entail delays; for example, waiting for output to
drain. A process in this state may not be killed, as it is already dying.
o If the parent process of the calling process has an outstanding wait call or catches the SIGCHLD signal, it is notified of the calling
process's termination; the status is set as defined by wait(2).
o The parent process-ID of all of the calling process's existing child processes are set to 1; the initialization process (see the DEFINI-
TIONS section of intro(2)) inherits each of these processes.
o If the termination of the process causes any process group to become orphaned (usually because the parents of all members of the group
have now exited; see ``orphaned process group'' in intro(2)), and if any member of the orphaned group is stopped, the SIGHUP signal and
the SIGCONT signal are sent to all members of the newly-orphaned process group.
o If the process is a controlling process (see intro(2)), the SIGHUP signal is sent to the foreground process group of the controlling ter-
minal. All current access to the controlling terminal is revoked.
Most C programs call the library routine exit(3), which flushes buffers, closes streams, unlinks temporary files, etc., before calling
_exit().
RETURN VALUE
_exit() can never return.
SEE ALSO
fork(2), sigaction(2), wait(2), exit(3)
STANDARDS
The _exit function is defined by IEEE Std 1003.1-1988 (``POSIX.1'').
4th Berkeley Distribution June 4, 1993 4th Berkeley Distribution