R
Ramesh
Hi All!
I have written a progarm which will create 10 child processes ( by
fork) to execure a method simuleneously; But the the child will do
database updates. In the parent I need database success/failure update
counts done by each child. For that I declared global two arrays to
assign in the child processes; But once the child process exists then
global variables coming to original values, the child updated values
are not reflecting once child existed; I tried even with static
member variables also;
two static member variable are declared:
static int fList[10] ;
static int sList[10] ;
Static def:
int C_SMSSvcRetroExpireProcess::sList[] = { 0 };
int C_SMSSvcRetroExpireProcess::fList[] = { 0 };
Fork:
for ( index = 0; index < MAX_PROCESSES && (pid = fork()) !
= 0 ; index++ )
{
// Spawned a number of child processes to be executed
// simultaneously.
........
}
// child process
if ( pid == 0 )
{
// this is the method to be called, which will update
database inturn
smsRetroExprEligibleSvcSuccessCount[index] =
processRetroRecs ( smsSvcDeactvVCltn,
startRecCount,
endRecCount,
fileSeqNbr++,
retroActiveAutoExprDays,
_smsRetroProcessDir,
recsEligibleForUpdate,
index,
childRetCode);
TRACE_BEGIN( APPLICATION ) << "After sList[" << index
<< "]="<< sList[index] << TRACE_END;
TRACE_BEGIN( APPLICATION ) << "After fList[" << index
<< "]="<< fList[index] << TRACE_END;
// exit the child
_exit(childRetCode); // Up to here I am able to print
the above two statement correctly
}
In the child process code I am able print the sList, fList correctly
but once _exit(childRetCode); is executed I lost the child update
values; I tried to declare the sList, fList as global and also
static;But still I am not able track the child update values;
How to retain the fList, sList in parent above even if the childs
exited? Please give me clue... Thank a lot
I have written a progarm which will create 10 child processes ( by
fork) to execure a method simuleneously; But the the child will do
database updates. In the parent I need database success/failure update
counts done by each child. For that I declared global two arrays to
assign in the child processes; But once the child process exists then
global variables coming to original values, the child updated values
are not reflecting once child existed; I tried even with static
member variables also;
two static member variable are declared:
static int fList[10] ;
static int sList[10] ;
Static def:
int C_SMSSvcRetroExpireProcess::sList[] = { 0 };
int C_SMSSvcRetroExpireProcess::fList[] = { 0 };
Fork:
for ( index = 0; index < MAX_PROCESSES && (pid = fork()) !
= 0 ; index++ )
{
// Spawned a number of child processes to be executed
// simultaneously.
........
}
// child process
if ( pid == 0 )
{
// this is the method to be called, which will update
database inturn
smsRetroExprEligibleSvcSuccessCount[index] =
processRetroRecs ( smsSvcDeactvVCltn,
startRecCount,
endRecCount,
fileSeqNbr++,
retroActiveAutoExprDays,
_smsRetroProcessDir,
recsEligibleForUpdate,
index,
childRetCode);
TRACE_BEGIN( APPLICATION ) << "After sList[" << index
<< "]="<< sList[index] << TRACE_END;
TRACE_BEGIN( APPLICATION ) << "After fList[" << index
<< "]="<< fList[index] << TRACE_END;
// exit the child
_exit(childRetCode); // Up to here I am able to print
the above two statement correctly
}
In the child process code I am able print the sList, fList correctly
but once _exit(childRetCode); is executed I lost the child update
values; I tried to declare the sList, fList as global and also
static;But still I am not able track the child update values;
How to retain the fList, sList in parent above even if the childs
exited? Please give me clue... Thank a lot