[LTP] [PATCH 1/7] openposix: pthread_rwlockattr_getpshared/2-1: Fix
Cyril Hrubis
chrubis@suse.cz
Mon Jun 20 11:21:40 CEST 2022
Propagate a failure in child to the parent properly.
Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
---
.../pthread_rwlockattr_getpshared/2-1.c | 20 +++++++++++++++++--
1 file changed, 18 insertions(+), 2 deletions(-)
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_rwlockattr_getpshared/2-1.c b/testcases/open_posix_testsuite/conformance/interfaces/pthread_rwlockattr_getpshared/2-1.c
index 3ffdc0cea..72c40f117 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/pthread_rwlockattr_getpshared/2-1.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_rwlockattr_getpshared/2-1.c
@@ -126,7 +126,11 @@ int main(void)
if (pid == -1) {
perror("Error at fork()");
return PTS_UNRESOLVED;
- } else if (pid > 0) {
+ }
+
+ if (pid > 0) {
+ int status;
+
/* Parent */
/* wait until child do wrlock */
while (rwlock_data->data == 0) {
@@ -141,7 +145,7 @@ int main(void)
printf("Parent unlocked.\n");
/* Wait for child to end */
- wait(NULL);
+ wait(&status);
if ((shm_unlink(shm_name)) != 0) {
perror("Error at shm_unlink()");
@@ -154,6 +158,16 @@ int main(void)
return PTS_FAIL;
}
+ if (!WIFEXITED(status)) {
+ printf("Parent: did not exit properly!\n");
+ return PTS_FAIL;
+ }
+
+ if (WEXITSTATUS(status)) {
+ printf("Parent: failure in child\n");
+ return WEXITSTATUS(status);
+ }
+
printf("Test PASSED\n");
return PTS_PASS;
} else {
@@ -195,5 +209,7 @@ int main(void)
rwlock_data->data = -1;
return PTS_FAIL;
}
+
+ return PTS_PASS;
}
}
--
2.35.1
More information about the ltp
mailing list