spawning multiple processes spread across two files


 
Thread Tools Search this Thread
Top Forums Programming spawning multiple processes spread across two files
# 1  
Old 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.
# 2  
Old 09-17-2007
Quote:
Originally Posted by StrengthThaDon
also is there a way to JUST spawn children? I don't understand why fork() would create parent processes.
You are missing the point.

Your code is executing within one process.

You call fork().

Your code is now executing in two processes, the original process and the child process,

fork() only creates one new process, the child process.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

Script on Solaris spawning 2 processes for one shell script execution

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

2. Shell Programming and Scripting

Shell script executed from Informatica ETL tool is spawning 2 processes for one script

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

3. AIX

Multiple pconsole processes spawning indefinetly

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

4. Shell Programming and Scripting

[AWK] handeling data spread on multiple lines

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

5. UNIX for Advanced & Expert Users

Help! imapd is spawning multiple processes, all of a sudden, for no reason!

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

6. Shell Programming and Scripting

search for a string spread in multiple line

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

7. UNIX for Advanced & Expert Users

Crontab spawning multiple at processes

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

8. Shell Programming and Scripting

removing pattern which is spread in multiple lines

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

9. Shell Programming and Scripting

Spawning multiple threads in Unix

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

10. UNIX for Dummies Questions & Answers

Can I spread commands over multiple lines?

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
Login or Register to Ask a Question