I need a mechanism to fork child processes and all child processes should connect to a server.but the number of child processes should be limited(for ex:50)
Here's my pseudo, but I cant figure out how to limit the child process number. Should I use a semaphore? or what?
PS: i use Linux.
I don't follow what these are...
this is what my text says...
"When a process is started, a duplicate of that process is created. This new process is called the child and the process that created it is called the parent. The child process then replaces the copy for the code the parent... (1 Reply)
Hello all, I am trying to create n child processes and control them from a parent process; say make child 3 print its pid and then child 5 do the same and some other stuff. Is there a way to accomplishing this after all the child processes are created via a call to fork().
Thank you,
FG (23 Replies)
Hello.
I have a global function name func1() that I am sourcing in from script A. I call the function from script B. Is there a way to find out which script called func1() dynamically so that the func1() can report it in the event there are errors?
Thanks (2 Replies)
Hello,
How many child processes are actually created when running this code ?
#include <signal.h>
#include <stdio.h>
int main () {
int i ;
setpgrp () ;
for (i = 0; i < 10; i++) {
if (fork () == 0) {
if ( i & 1 ) setpgrp () ;
printf ("Child id: %2d, group: %2d\n", getpid(),... (0 Replies)
Hello,
How many child processes are actually created when running this code ?
#include <signal.h>
#include <stdio.h>
int main () {
int i ;
setpgrp () ;
for (i = 0; i < 10; i++) {
if (fork () == 0) {
if ( i & 1 ) setpgrp () ;
printf ("Child id: %2d, group: %2d\n",... (1 Reply)
I have a parent process which will start 36 child process. This I achieved by using the 'for loop'.
In Parent.sh:-
./Child.sh <arg1> <arg2> ... &
If I execute "ps -ef | grep Child.sh", I can see 72 child processes running at the background. I mean I can see the duplicate of each process.
... (2 Replies)
Hi,
I have parent script which is invoking multiple child scripts. I would want to kill all the child processes before the parent
process exit.
> cat ./parent
#!/bin/ksh
while
do
. ./child arg1 &
if ; then
break
fi
done
Is there a way to get the process group id for all the child... (3 Replies)
I am trying to implement the below using Ksh script on a Lx machine.
There is a file(input_file) with 100K records. For each of these records, certain script(process_rec) needs to be called with the record as input. Sequential processing is time-consuming and parallel processing would eat up... (2 Replies)
is there a universal way of getting the children of a particular process? i'm looking for a solution that works across different OSes...linux, aix, sunos, hpux.
i did a search online and i kept finding answers that were specific to Linux..i.e. pstree.
i want to be able to specify a process... (2 Replies)
Discussion started by: SkySmart
2 Replies
LEARN ABOUT FREEBSD
vfork
VFORK(2) BSD System Calls Manual VFORK(2)NAME
vfork -- create a new process without copying the address space
LIBRARY
Standard C Library (libc, -lc)
SYNOPSIS
#include <unistd.h>
pid_t
vfork(void);
DESCRIPTION
The vfork() system call can be used to create new processes without fully copying the address space of the old process, which is horrendously
inefficient in a paged environment. It is useful when the purpose of fork(2) would have been to create a new system context for an
execve(2). The vfork() system call differs from fork(2) in that the child borrows the parent's memory and thread of control until a call to
execve(2) or an exit (either by a call to _exit(2) or abnormally). The parent process is suspended while the child is using its resources.
The vfork() system call returns 0 in the child's context and (later) the pid of the child in the parent's context.
The vfork() system call can normally be used just like fork(2). It does not work, however, to return while running in the child's context
from the procedure that called vfork() since the eventual return from vfork() would then return to a no longer existent stack frame. Be
careful, also, to call _exit(2) rather than exit(3) if you cannot execve(2), since exit(3) will flush and close standard I/O channels, and
thereby mess up the parent processes standard I/O data structures. (Even with fork(2) it is wrong to call exit(3) since buffered data would
then be flushed twice.)
RETURN VALUES
Same as for fork(2).
SEE ALSO _exit(2), execve(2), fork(2), rfork(2), sigaction(2), wait(2), exit(3)HISTORY
The vfork() system call appeared in 2.9BSD.
BUGS
To avoid a possible deadlock situation, processes that are children in the middle of a vfork() are never sent SIGTTOU or SIGTTIN signals;
rather, output or ioctl(2) calls are allowed and input attempts result in an end-of-file indication.
BSD November 13, 2009 BSD