Hi guys
Thank you very much for the help so far ,Iam new to QNX programming , just started in last three weeks, so forgive me if I ask some simple questions , but some stuff it doesnt seems to click for me right away :
iam confused now , I have the following code :
pid1=spawnl(NOWAIT ,"/fs0p0/bin/Mgr","/fs0p0/bin/Mgr", “1”,“0”,NULL);
printf( “pid of running process is %d\r\n”,pid1);
pid2=spawnl(P_NOWAIT ,"/fs0p0/bin/Mgr","/fs0p0/bin/Mgr", “2”,“0”,NULL);
printf( “pid of running process is %d\r\n”,pid2);
pid3=spawnl(P_WAIT ,"/fs0p0/bin/Mgr","/fs0p0/bin/Mgr", “3”,“0”,NULL);
printf( “pid of running process is %d\r\n”,pid3);
// *****************POINT A*****************
pid4 = waitpid(pid1,&stat_loc,WEXITED);
pid5 = waitpid(pid2,&stat_loc,WEXITED);
rintf("***********P1 ID %d ended with rc %d\r\n",pid4,stat_loc);
printf("***********P2 ID %d ended with rc %d\r\n",pid5,stat_loc);
printf("***********P3 ID %d ended with rc %d\r\n",pid3,stat_loc);
from what I understood of the documentation , that my C program , should not go to the line (POINT A) unless the three child processes end execution, but what happening here is that the (printf) lines after (POINT A) is getting executed , even before the three processes above it finish.
my goal is that my program to wait for the three processes to finish then continue of anything iam doing. can somebody explain what is the problem.