* [LTP] [PATCH v2] open_posix: Add failure handling of fork()
@ 2021-09-20 22:12 Zhao Gongyi
2021-09-23 8:23 ` Li Wang
0 siblings, 1 reply; 3+ messages in thread
From: Zhao Gongyi @ 2021-09-20 22:12 UTC (permalink / raw)
To: ltp
When fork() failed and transfer the return value(-1) to kill(),
it would freeze the system, so it is very serious in this
cases and should be avoided.
Signed-off-by: Zhao Gongyi <zhaogongyi@huawei.com>
---
.../conformance/interfaces/clock_nanosleep/1-5.c | 5 ++++-
.../conformance/interfaces/nanosleep/3-2.c | 5 ++++-
.../conformance/interfaces/sigaction/10-1.c | 5 ++++-
.../conformance/interfaces/sigaction/11-1.c | 5 ++++-
.../conformance/interfaces/sigaction/9-1.c | 5 ++++-
5 files changed, 20 insertions(+), 5 deletions(-)
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/clock_nanosleep/1-5.c b/testcases/open_posix_testsuite/conformance/interfaces/clock_nanosleep/1-5.c
index 263d98a08..7c09d7599 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/clock_nanosleep/1-5.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/clock_nanosleep/1-5.c
@@ -35,7 +35,10 @@ int main(void)
return PTS_UNRESOLVED;
}
- if ((pid = fork()) == 0) {
+ if ((pid = fork()) < 0) {
+ printf("fork() did not return success\n");
+ return PTS_UNRESOLVED;
+ } else if (pid == 0) {
/* child here */
struct timespec tssleep;
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/nanosleep/3-2.c b/testcases/open_posix_testsuite/conformance/interfaces/nanosleep/3-2.c
index 4016fb4e6..bfc271edf 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/nanosleep/3-2.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/nanosleep/3-2.c
@@ -31,7 +31,10 @@ int main(void)
return PTS_UNRESOLVED;
}
- if ((pid = fork()) == 0) {
+ if ((pid = fork()) < 0) {
+ printf("fork() did not return success\n");
+ return PTS_UNRESOLVED;
+ } else if (pid == 0) {
/* child here */
struct timespec tssleep;
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/sigaction/10-1.c b/testcases/open_posix_testsuite/conformance/interfaces/sigaction/10-1.c
index 02150a150..722cbf2b5 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/sigaction/10-1.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/sigaction/10-1.c
@@ -66,7 +66,10 @@ int main(void)
sigemptyset(&act.sa_mask);
sigaction(SIGCHLD, &act, 0);
- if ((pid = fork()) == 0) {
+ if ((pid = fork()) < 0) {
+ printf("fork() did not return success\n");
+ return PTS_UNRESOLVED;
+ } else if (pid == 0) {
/* child */
while (1) {
/* wait forever, or until we are
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/sigaction/11-1.c b/testcases/open_posix_testsuite/conformance/interfaces/sigaction/11-1.c
index 41db84865..fcf5e7837 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/sigaction/11-1.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/sigaction/11-1.c
@@ -51,7 +51,10 @@ int main(void)
sigemptyset(&act.sa_mask);
sigaction(SIGCHLD, &act, 0);
- if ((pid = fork()) == 0) {
+ if ((pid = fork()) < 0) {
+ printf("fork() did not return success\n");
+ return PTS_UNRESOLVED;
+ } else if (pid == 0) {
/* child */
while (1) {
/* wait forever, or until we are
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/sigaction/9-1.c b/testcases/open_posix_testsuite/conformance/interfaces/sigaction/9-1.c
index 1d45c09c6..dc3200eae 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/sigaction/9-1.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/sigaction/9-1.c
@@ -51,7 +51,10 @@ int main(void)
sigemptyset(&act.sa_mask);
sigaction(SIGCHLD, &act, 0);
- if ((pid = fork()) == 0) {
+ if ((pid = fork()) < 0) {
+ printf("fork() did not return success\n");
+ return PTS_UNRESOLVED;
+ } else if (pid == 0) {
/* child */
/* wait forever, or until we are
interrupted by a signal */
--
2.17.1
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [LTP] [PATCH v2] open_posix: Add failure handling of fork()
2021-09-20 22:12 [LTP] [PATCH v2] open_posix: Add failure handling of fork() Zhao Gongyi
@ 2021-09-23 8:23 ` Li Wang
2021-09-24 3:12 ` Li Wang
0 siblings, 1 reply; 3+ messages in thread
From: Li Wang @ 2021-09-23 8:23 UTC (permalink / raw)
To: Zhao Gongyi; +Cc: LTP List
[-- Attachment #1.1: Type: text/plain, Size: 354 bytes --]
On Thu, Sep 23, 2021 at 3:42 PM Zhao Gongyi <zhaogongyi@huawei.com> wrote:
> When fork() failed and transfer the return value(-1) to kill(),
> it would freeze the system, so it is very serious in this
> cases and should be avoided.
>
> Signed-off-by: Zhao Gongyi <zhaogongyi@huawei.com>
>
Reviewed-by: Li Wang <liwang@redhat.com>
--
Regards,
Li Wang
[-- Attachment #1.2: Type: text/html, Size: 1033 bytes --]
[-- Attachment #2: Type: text/plain, Size: 60 bytes --]
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [LTP] [PATCH v2] open_posix: Add failure handling of fork()
2021-09-23 8:23 ` Li Wang
@ 2021-09-24 3:12 ` Li Wang
0 siblings, 0 replies; 3+ messages in thread
From: Li Wang @ 2021-09-24 3:12 UTC (permalink / raw)
To: Zhao Gongyi; +Cc: LTP List
[-- Attachment #1.1: Type: text/plain, Size: 38 bytes --]
Merged. Thanks!
--
Regards,
Li Wang
[-- Attachment #1.2: Type: text/html, Size: 248 bytes --]
[-- Attachment #2: Type: text/plain, Size: 60 bytes --]
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-09-24 3:13 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-20 22:12 [LTP] [PATCH v2] open_posix: Add failure handling of fork() Zhao Gongyi
2021-09-23 8:23 ` Li Wang
2021-09-24 3:12 ` Li Wang
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.