Problem due to Fork Error


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Problem due to Fork Error
# 8  
Old 07-14-2008
It's simple enough.
Code:
#define MAXC 25
pid_t do_child(char *cmd, char *args[]);

int main(void) {
int v = 0, x =0;
pid_t p_arrays[MAXC];

            while (v  <  MAXC) {p_arrays[v] = do_child(...); v++);
            while (x < (MAXC - 1)) {
                   if (waitpid(0,NULL,WNOHANG)) > 0) {x++;}
                   sleep(1);
             }
}
/*do_child with fork + execv is simple as is parsing and passing args to do_child in main*/

# 9  
Old 09-04-2008
MySQL

Sorry for the delay Smilie
And thanks all for your replies.. Smilie

I really helped..Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Very basic problem with fork() using c

Hi guys, I have the following code: int main(int argc, char *argv) { int pid1,pid2,i=0; pid1=fork(); i+=2; if(!pid1) i++; if(i%3) pid2=fork(); if (pid2==0) { printf("sea \n "); i-=1; } if(i>=2)... (4 Replies)
Discussion started by: pfpietro
4 Replies

2. Programming

problem with mutltiple fork()

Hi, can someone please help me with creating mutltiple fork.. I was expecting something like this: I am a child: 1 PID: 1215 I am a child: 2 PID: 1216 I am a child: 3 PID: 1217 I am a child: 4 PID: 1218 I am a child: 5 PID: 1219 I am a child: 6 PID: 1215 I am a child: 7 PID: 1216 I am a... (4 Replies)
Discussion started by: Placenzo
4 Replies

3. Programming

help in C of fork() problem

i am a beginner of C, and i tired to fork multiple child and all of them belongs to same parents and each of child responsible for printing individual data. but i don't have any idea how to do...... Can any body help? thanks a lot really. (7 Replies)
Discussion started by: wendy1089
7 Replies

4. IP Networking

FTP failure due to network problem

Hi, I've been searching through out this forum to find the exact message when during the on-going FTP, suddenly the network went down but i cannot find some. Could anyone provide me the exact return codes when FTP failed during FTP or prior to FTP the network went down and you still proceeded to... (3 Replies)
Discussion started by: vibora
3 Replies

5. SCO

Booting problem due to adding hard drive incorrectly

I have tried to (unsuccessfully) add an old drive to get drivers (for the 3Com network card) onto a Sco Openserver 5.1 server. Now it wont boot: I used Sco Admin to do this. It have 3 scuzzi drives I added an IDE I think what I did wrong was add the IDE to existing space, and I should not have... (6 Replies)
Discussion started by: lappies67
6 Replies

6. Programming

problem implementing fork

Hi, I was honing my linux programming skill when this nuisance started bugging me. I wanted to create an empty file creator program. While creating a large file it must print # for progress bar. But the output shows it happening reverse way. ie. first it copies file and shows the progress... (7 Replies)
Discussion started by: dheerajsuthar
7 Replies

7. Shell Programming and Scripting

Script problem due to recursive directories Help please

Hello everyone , I am looking for a better solution then the one I have created for the my Task The task is: Create an automated script that will check for Uploads in a specified Directory and move them to another specified Directory if the files are completely uploaded. Files are FTP'd to... (2 Replies)
Discussion started by: robertmcol
2 Replies

8. Filesystems, Disks and Memory

ACL problem due to mv command used in solaris

Hi All, Is there any way to use mv command and that should apply ACL on the moved files that is already set in distination location This mv command is running in a solaris system. File system is NFS. Problem I am facing : Currently mv command removes ACL from moved files and also it... (0 Replies)
Discussion started by: Tlogine
0 Replies

9. Programming

fork() problem

i'm just trying to make 2 process read from the same 1 line a time. For some reason only the child reads. #include<stdio.h> #include <sys/types.h> void getlinefromfilep(void); void getlinefromfilec(void); int see=0; FILE * fileptr1; //need globe variable to tell pro3 to stop main()... (3 Replies)
Discussion started by: ddx08
3 Replies

10. Programming

fork problem

Hi, Consider the following piece of code: int main(void) { int i; pid_t pidp; for (i=0;i<4;i++) { switch (pidp=fork()) { case -1: fprintf(stdout, "Error during fork.\n"); exit (1); case 0: fprintf(stdout, "From child: I am... (4 Replies)
Discussion started by: qntmteleporter
4 Replies
Login or Register to Ask a Question