Skip to content

Commit d362ab0

Browse files
committed
Correcting host code for negative tests
1 parent 880314f commit d362ab0

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

sys_opt/multiple_process/src/host.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,15 @@ 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);
177+
for (int i = 0; i < iter; i++) {
178+
int status = 0;
179+
int child = wait(&status);
180+
std::cout << "[PID: " << getpid() << "] child: " << child
181+
<< " exited with WIFEXITED: " << WIFEXITED(status)
182+
<< " and WEXITSTATUS: " << WEXITSTATUS(status) << std::endl;
183+
if (WEXITSTATUS(status))
184+
result = false;
185+
}
179186
std::cout << "\n[PID: " << getpid() << "] PARENT WAITS CHILD TO FINISH.\n\n"
180187
<< std::endl;
181188

0 commit comments

Comments
 (0)