File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed
sys_opt/multiple_process/src Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -174,10 +174,17 @@ int main(int argc, char *argv[]) {
174174 }
175175
176176 // Need to wait for all child process to complete
177- for (int i = 0 ; i < iter; i++)
178- wait (NULL );
179177 std::cout << " \n [PID: " << getpid () << " ] PARENT WAITS CHILD TO FINISH.\n\n "
180178 << std::endl;
179+ for (int i = 0 ; i < iter; i++) {
180+ int status = 0 ;
181+ int child = wait (&status);
182+ std::cout << " [PID: " << getpid () << " ] child: " << child
183+ << " exited with WIFEXITED: " << WIFEXITED (status)
184+ << " and WEXITSTATUS: " << WEXITSTATUS (status) << std::endl;
185+ if (WEXITSTATUS (status) and WIFEXITED (status))
186+ result = false ;
187+ }
181188
182189 std::cout << " TEST " << ((result) ? " PASSED" : " FAILED" ) << std::endl;
183190 return ((result) ? EXIT_SUCCESS : EXIT_FAILURE);
You can’t perform that action at this time.
0 commit comments