Skip to content

Commit 8c61256

Browse files
Bhaskar VishnuVardhan ChebroluGitHub Enterprise
authored andcommitted
Correcting host code for negative tests
2 parents ca3a5dd + 04c524e commit 8c61256

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,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);

0 commit comments

Comments
 (0)