Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: ProC and fork()

Re: ProC and fork()

From: Cédric Avenas <cedric.avenas_at_ad6.com>
Date: Mon, 13 Dec 1999 16:38:33 +0100
Message-ID: <8333a8$pg3$1@news.imaginet.fr>


Christian,
1/ Create a Proc C thread (standard Pro C program) which will do what you want (it's your futur child)
2/ Use a "exec" (which call and load the binary executable that you create in 1/) command after your "fork" command in your father program.

Then your child process can access your database during your father process do the same (or anything else).
Your father process will detect the death child by a call to "waitpid" command.

        That's all..

Christian Smith a écrit dans le message <384ED21A.F73B50F4_at_christiansmith.com>...
>I've been playing around with fork and would like to fork off certain
>process (database fetches & updates) and keep processing until that
>fetch comes back. I've found that when you do a fork the child proces
>that does the fork stop running when it accesses the database. Below is
>some sample code that fork's 2 procedures - the procedures do updates on
>a couple of columns. By using sleeps and print statements I've found
>that it will start the first ParseBif099Address updates until the 2 fork
>starts then the process stops.
>
>Any clues as to how I could do this....
>
>int DoPreprocessingSteps(FLAGS *pFlags)

>
>
> pid_t ArgList[NUMPROCESSES];
> pid_t TmpArg=0;
> int SigList[NUMPROCESSES];
> int StatusList[NUMPROCESSES];
> int i;
>
> memset(SigList,0,sizeof(StatusList));
> memset(StatusList,0,sizeof(StatusList));
> memset(ArgList,1,sizeof(ArgList));
>
> if (pFlags->Parse)

> if ( (ArgList[PARSEBIF099] = fork()) == 0 )

> printf("......Running ParseBif099Address\n");
> ParseBif099Address();
> exit(0);
> }
> } else StatusList[PARSEBIF099] = 1;
>
> if (pFlags->CombAccount)

> if ( (ArgList[COMBACCT] = fork()) == 0 )

> printf(".......Running ProcessCombinationAccounts\n");
> ProcessCombinationAccounts();
> exit(0);
> }
>
> } else StatusList[COMBACCT] = 1;
>
> /* Starting the loop */
> printf(".....Starting the loop\n");
> while ( !StatusList[COMBACCT] || !StatusList[PARSEBIF099] )

> if (StatusList[COMBACCT] != ArgList[COMBACCT])

> StatusList[COMBACCT] = waitpid(ArgList[COMBACCT],NULL,WNOHANG);
> if ( StatusList[COMBACCT] == -1 )

> fprintf(stderr, "Error With Spawning Process CombAcct");
> exit2os(EXIT_FAILURE);
> }
> }
> if (StatusList[PARSEBIF099] != ArgList[PARSEBIF099])

> StatusList[PARSEBIF099] =
>waitpid(ArgList[PARSEBIF099],NULL,WNOHANG);
> if (StatusList[PARSEBIF099] == -1 )

> fprintf(stderr, "Error With Spawing Process
>PARSEBIF099");
> exit2os(EXIT_FAILURE);
> }
> }
> fprintf(stderr, "Sleeping - Wainting For processed 1 %d 2 %d 1 %d 2
>%d\n",
> StatusList[COMBACCT], StatusList[PARSEBIF099],
> ArgList[COMBACCT], ArgList[PARSEBIF099]);
>
> sleep(60);
> }
>
>}
Received on Mon Dec 13 1999 - 09:38:33 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US