09-17-2007
spawning multiple processes spread across two files
I want to spawn n child processes but have two different classes..with the foremost one forking/spawning the child process and the latter performing a function w/ the spawned processes.
I can do this in one class with an if statement and the simple
if((pid=fork())==0) //child process
{
//do code
}
else
{
//do code as parent process.
}
In doing in w/ two different classes would I need to pass fork() to the slave class? I don't to fork my main process and have it execute the same code as the parent process I want it to execute its own code. That's why I want a separate child/slave class.
also is there a way to JUST spawn children? I don't understand why fork() would create parent processes.
Hopefully my problem isn't too convoluted, thanks.
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Below an example of what I mean. The first attempt does what I want; the second doesn't, because bash assumes a line break means the end of an individual "command unix". Is there some way that I can convince bash to parse out, eg, to the closing parenthesis?
I'm thinking this would allow for... (1 Reply)
Discussion started by: tphyahoo
1 Replies
2. Shell Programming and Scripting
Hi,
I need to spawn mutilpe threads , each invoking a different set of shell scripts, in parallel.
What would be the best way to do that.
Any sample script would greatly help. I am a novice at Unix so any help is much appreciated.
Thanks (5 Replies)
Discussion started by: neeto
5 Replies
3. Shell Programming and Scripting
I have several huge files wich contains oracle table creation scripts as follows:
I would need to remove the pattern colored in red above. Any sed/awk/pearl code will be of much help.
Thanks (2 Replies)
Discussion started by: sabyasm
2 Replies
4. UNIX for Advanced & Expert Users
Hi - I need help. My user crontab is spawning multiple at processes (and multiple mencoder program starts, that exit, then restart, repeatedly), locking up my system.
For example I have this entry in my crontab:
$ sudo crontab -u victoria -e
* * * * * ~/recordings/pvr1
* * * * *... (10 Replies)
Discussion started by: gstuart
10 Replies
5. Shell Programming and Scripting
Hi,
I have to look for the full string below in a large file(>5GB) , but that string may be spread in two lines.
string :-- "f8f8 f5f0 f0f0 f1f7 f4f7 f7c1"
By grep "f8f8 f5f0 f0f0 f1f7 f4f7 f7c1" file | tail -1
, I am getting incorrect result because there is a line after this also which... (1 Reply)
Discussion started by: finder255
1 Replies
6. UNIX for Advanced & Expert Users
Hi All,
I need some assistance, if possible...
Our IMAP server has recently (as of 10:30 GMT today) started spawning multiple processes for no reason! This is causing the mail server's load average to increase continually until the whole machine grinds to a halt.
Here is a typical... (0 Replies)
Discussion started by: fishsponge
0 Replies
7. Shell Programming and Scripting
Hello all,
first off great forum.
Now for my little problem.
Using RHEL 5.4 and awk. Been doing code since a few month. So just starting.
My problem is handeling data on multiple lines.
{
if ($1 != LASTKEY && h ~ /.*\/s_fr_/) {
checkgecos( h, h )
h=""
... (2 Replies)
Discussion started by: maverick72
2 Replies
8. AIX
Good night everyone, I've been trying to make AD authentication work with RBAC and I think I messed my test LPAR up.
I've manually modified the /etc/security/user.roles file, adding a role to one of my AD users (who is not defined locally) and then runned setkst. It worked fine, but now I found... (3 Replies)
Discussion started by: Janpol
3 Replies
9. Shell Programming and Scripting
Hi,
I am having a shell script which has a while loop as shown below.
while
do
sleep 60
done
I am executing this script from Informatica ETL tool command task from where we can execute UNIX commands/scripts. When i do that, i am seeing 2 processes getting started for one script... (2 Replies)
Discussion started by: chekusi
2 Replies
10. Solaris
Hi,
I am having a shell script on Solaris 10 which has a while loop as shown below.
#!/usr/bin/ksh
#
while
do
sleep 60
done
Name of the shell script is coldcentric.sh. I executed script /DATAWAREHOUSE/LOAD/Scripts/coldcentric.sh from a command task in Informatica worklow as... (3 Replies)
Discussion started by: chekusi
3 Replies
VFORK(2) System Calls Manual VFORK(2)
NAME
vfork - spawn new process in a virtual memory efficient way
SYNOPSIS
pid = vfork()
int pid;
DESCRIPTION
Vfork 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. Vfork differs
from fork 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.
Vfork returns 0 in the child's context and (later) the pid of the child in the parent's context.
Vfork can normally be used just like fork. It does not work, however, to return while running in the childs 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 rather than exit if you can't execve, since exit will flush and close standard I/O channels, and thereby mess up the parent processes
standard I/O data structures. (Even with fork it is wrong to call exit since buffered data would then be flushed twice.)
SEE ALSO
fork(2), execve(2), sigvec(2), wait(2),
DIAGNOSTICS
Same as for fork.
BUGS
This system call will be eliminated when proper system sharing mechanisms are implemented. Users should not depend on the memory sharing
semantics of vfork as it will, in that case, be made synonymous to fork.
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 ioctls are allowed and input attempts result in an end-of-file indication.
4th Berkeley Distribution June 30, 1985 VFORK(2)