| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> c.d.o.server -> ProC and fork()
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 Wed Dec 08 1999 - 15:48:10 CST
![]() |
![]() |