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.
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
LEARN ABOUT MOJAVE
pthread_atfork
PTHREAD_ATFORK(3) BSD Library Functions Manual PTHREAD_ATFORK(3)
NAME
pthread_atfork -- register handlers to be called before and after fork()
SYNOPSIS
#include <pthread.h>
int
pthread_atfork(void (*prepare)(void), void (*parent)(void), void (*child)(void));
DESCRIPTION
The pthread_atfork() function declares fork handlers to be called before and after fork(2), in the context of the thread that called fork(2).
The handlers registered with pthread_atfork() are called at the moments in time described below:
prepare Before fork(2) processing commences in the parent process. If more than one prepare handler is registered they will be called in
the opposite order they were registered.
parent After fork(2) completes in the parent process. If more than one parent handler is registered they will be called in the same order
they were registered.
child After fork(2) processing completes in the child process. If more than one child handler is registered they will be called in the
same order they were registered.
If no handling is desired at one or more of these three points, a null pointer may be passed as the corresponding fork handler.
Important: only async-signal-safe functions are allowed on the child side of fork(). See sigaction(2) for details.
RETURN VALUES
If successful, the pthread_atfork() function will return zero. Otherwise an error number will be returned to indicate the error.
ERRORS
The pthread_atfork() function will fail if:
[ENOMEM] The system lacked the necessary resources to add another handler to the list.
SEE ALSO
fork(2), pthread(3)
STANDARDS
The pthread_atfork() conforms to ISO/IEC 9945-1:1996 (``POSIX.1'').
BSD
June 21, 2004 BSD