Option 1: fork twice (pseudocode)
Option 2: remember how many forks you've done in an array (no guarantee on correctness):
Personally, I think the first one is better in terms of readability.
Hello all.
I'm developing a filetransfer application, which is supposed to work sort of like dcc, with multiple transfers etc. Now i wonder what the best way to manage the transfers is. Should i fork() for each new transfer, hogging loads of memory or use pthreads? Maybe I can use select to see... (0 Replies)
hi all
About this code
for (i = 1; i < n; i++)
if ((childpid = fork()) <= 0)
break;
I really can't understand the output .
and the way fork () return the value .
how about the process Id ,the child process Id and the parent ID
in this case
so please answer me soon (5 Replies)
Hi everybody,
I wanna write a code to understand how fork works.
my target
--------------
-Parent creates a file(called temp) and writes into this file "1".Then it closes the file.
-Then parent creates a child and wait until execution of this child ends.
-Then child opens the same... (3 Replies)
I have never coded in perl before (just started today morning :). I need to write a perl program to automate a task.
Here is how I do it manually:
Start a program in my home dir. Now if I want to execute another program while this one is still running, what I would do is go to another... (6 Replies)
I'm trying to run a simple test on how to use fork(), i'm able to execute the child process first then the parent, but how can I execute parent then child..?
Thanks! (1 Reply)
Hi,
I have a file which has some 50 hosts, I want to login to each host using ssh and execute any command. I am using fork function in perl. I am able to login to each host and execute the command in the hosts paralelly, but it spawing/forking 50 processes at a time.
It will consume the cpu... (5 Replies)
I understand that fork create a child but I need very simple example that make child useful....
I mean how will make the program faster anyone explain with code plz
using C plz (2 Replies)
Hi,
I am breaking my head to understand the below line of code in perl:
next if $pid = fork; # Parent goes to next server.
die "fork failed: $!" unless defined $pid;
Can anyone please explain me in detail as I am a slow learner?
Thanks,
Ali. (2 Replies)
Discussion started by: liyakathali
2 Replies
LEARN ABOUT HPUX
pthread_atfork
pthread_atfork(3T)pthread_atfork(3T)NAME
pthread_atfork() - register fork handlers.
SYNOPSIS PARAMETERS
prepare This function is called before performing the
parent This function is called in the parent process after performing the
child This function is called in the child process after performing the
DESCRIPTION
The function allows an application to install fork handlers. These fork handlers will be called before and after a operation. These han-
dlers will be called in the context of the thread calling Similar to the handlers, the application does not need to do anything special for
these fork handlers to be called. They will be invoked by the system when a operation occurs.
The function is called before the operation in the parent process. The function is called after the operation in the parent process. The
function is called after the operation in the child process.
If a fork handler is not needed in one or more of these three places, the appropriate fork handler parameter may be set to NULL.
A process may install multiple fork handling functions. The and fork handlers will be called in the order in which they were installed
(i.e., The fork handlers will be called in the opposite order (i.e.,
RETURN VALUE
Upon successful completion, returns zero. Otherwise, an error number is returned to indicate the error (the variable is not set).
ERRORS
If any of the following occur, the function returns the corresponding error number:
[ENOMEM] There is insufficient table space to install the fork handlers.
AUTHOR
was derived from the IEEE POSIX P1003.1c standard.
SEE ALSO fork(2), atexit(3).
STANDARDS CONFORMANCE
Pthread Library pthread_atfork(3T)