All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [LTP] [PATCH] open_posix: Add failure handling of fork()
@ 2021-09-23  7:49 zhaogongyi
  0 siblings, 0 replies; 3+ messages in thread
From: zhaogongyi @ 2021-09-23  7:49 UTC (permalink / raw)
  To: Li Wang; +Cc: LTP List


[-- Attachment #1.1: Type: text/plain, Size: 2050 bytes --]

Hi Li,

I have modified the patch as your review, please see: https://patchwork.ozlabs.org/project/ltp/patch/20210920221212.8478-1-zhaogongyi@huawei.com/

Thanks so much!

发件人: Li Wang [mailto:liwang@redhat.com]
发送时间: 2021年9月8日 11:30
收件人: zhaogongyi <zhaogongyi@huawei.com>
抄送: LTP List <ltp@lists.linux.it>
主题: Re: [LTP] [PATCH] open_posix: Add failure handling of fork()



On Tue, Sep 7, 2021 at 8:41 PM Zhao Gongyi <zhaogongyi@huawei.com<mailto:zhaogongyi@huawei.com>> wrote:
When fork() failed and transfer the return value(-1) to kill(),
kill(-1, SIGSTOP) would freeze the system, so it is very serious
in this cases and should be avoided.

Signed-off-by: Zhao Gongyi <zhaogongyi@huawei.com<mailto:zhaogongyi@huawei.com>>
---
 .../conformance/interfaces/clock_nanosleep/1-5.c               | 3 +++
 .../conformance/interfaces/nanosleep/3-2.c                     | 3 +++
 .../conformance/interfaces/sigaction/10-1.c                    | 3 +++
 .../conformance/interfaces/sigaction/11-1.c                    | 3 +++
 .../conformance/interfaces/sigaction/9-1.c                     | 3 +++
 5 files changed, 15 insertions(+)

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 46f26163d..a87585884 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
@@ -48,6 +48,9 @@ int main(void)
                        return CHILDFAIL;
                }
                return CHILDFAIL;
+       } else if (pid < 0) {
+               printf("fork() did not return success\n");
+               return PTS_UNRESOLVED;

Can we do the error check following the fork() instantly?
Insert pid<0 with a 'else if' looks a bit strange here.

Normally convention like:

pid = fork();
 if (pid < 0)
    do error handle ...

--
Regards,
Li Wang

[-- Attachment #1.2: Type: text/html, Size: 8361 bytes --]

[-- Attachment #2: Type: text/plain, Size: 60 bytes --]


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [LTP] [PATCH] open_posix: Add failure handling of fork()
@ 2021-09-08  3:29     ` Li Wang
  0 siblings, 0 replies; 3+ messages in thread
From: Li Wang @ 2021-09-08  3:29 UTC (permalink / raw)
  To: Zhao Gongyi; +Cc: LTP List


[-- Attachment #1.1: Type: text/plain, Size: 1586 bytes --]

On Tue, Sep 7, 2021 at 8:41 PM Zhao Gongyi <zhaogongyi@huawei.com> wrote:

> When fork() failed and transfer the return value(-1) to kill(),
> kill(-1, SIGSTOP) 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               | 3 +++
>  .../conformance/interfaces/nanosleep/3-2.c                     | 3 +++
>  .../conformance/interfaces/sigaction/10-1.c                    | 3 +++
>  .../conformance/interfaces/sigaction/11-1.c                    | 3 +++
>  .../conformance/interfaces/sigaction/9-1.c                     | 3 +++
>  5 files changed, 15 insertions(+)
>
> 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 46f26163d..a87585884 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
> @@ -48,6 +48,9 @@ int main(void)
>                         return CHILDFAIL;
>                 }
>                 return CHILDFAIL;
> +       } else if (pid < 0) {
> +               printf("fork() did not return success\n");
> +               return PTS_UNRESOLVED;
>

Can we do the error check following the fork() instantly?
Insert pid<0 with a 'else if' looks a bit strange here.

Normally convention like:

pid = fork();
 if (pid < 0)
    do error handle ...

-- 
Regards,
Li Wang

[-- Attachment #1.2: Type: text/html, Size: 2802 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

* [LTP] [PATCH] open_posix: Add failure handling of fork()
@ 2021-09-05  3:11 ` Zhao Gongyi
  2021-09-08  3:29     ` Li Wang
  0 siblings, 1 reply; 3+ messages in thread
From: Zhao Gongyi @ 2021-09-05  3:11 UTC (permalink / raw)
  To: ltp

When fork() failed and transfer the return value(-1) to kill(),
kill(-1, SIGSTOP) 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               | 3 +++
 .../conformance/interfaces/nanosleep/3-2.c                     | 3 +++
 .../conformance/interfaces/sigaction/10-1.c                    | 3 +++
 .../conformance/interfaces/sigaction/11-1.c                    | 3 +++
 .../conformance/interfaces/sigaction/9-1.c                     | 3 +++
 5 files changed, 15 insertions(+)

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 46f26163d..a87585884 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
@@ -48,6 +48,9 @@ int main(void)
 			return CHILDFAIL;
 		}
 		return CHILDFAIL;
+	} else if (pid < 0) {
+		printf("fork() did not return success\n");
+		return PTS_UNRESOLVED;
 	} else {
 		/* parent here */
 		int i;
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..472dd48ba 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/nanosleep/3-2.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/nanosleep/3-2.c
@@ -45,6 +45,9 @@ int main(void)
 			return CHILDFAIL;
 		}
 		return CHILDFAIL;
+	} else if ( pid < 0) {
+		printf("fork() did not return success\n");
+		return PTS_UNRESOLVED;
 	} else {
 		/* parent here */
 		int i;
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..2212c98f0 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/sigaction/10-1.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/sigaction/10-1.c
@@ -76,6 +76,9 @@ int main(void)
 			select(0, NULL, NULL, NULL, &tv);
 		}
 		return 0;
+	} else if (pid < 0) {
+		printf("fork() did not return success\n");
+		return PTS_UNRESOLVED;
 	} else {
 		/* parent */
 		int s;
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..a88e969dc 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/sigaction/11-1.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/sigaction/11-1.c
@@ -61,6 +61,9 @@ int main(void)
 			select(0, NULL, NULL, NULL, &tv);
 		}
 		return 0;
+	} else if (pid < 0) {
+		printf("fork() did not return success\n");
+		return PTS_UNRESOLVED;
 	} else {
 		/* parent */
 		int s;
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..70df68332 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/sigaction/9-1.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/sigaction/9-1.c
@@ -57,6 +57,9 @@ int main(void)
 		   interrupted by a signal */
 		select(0, NULL, NULL, NULL, NULL);
 		return 0;
+	} else if (pid < 0) {
+		printf("fork() did not return success\n");
+		return PTS_UNRESOLVED;
 	} else {
 		/* parent */
 		int s;
--
2.17.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-09-23  7:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-23  7:49 [LTP] [PATCH] open_posix: Add failure handling of fork() zhaogongyi
  -- strict thread matches above, loose matches on Subject: below --
2021-09-05  3:11 Zhao Gongyi
2021-09-05  3:11 ` Zhao Gongyi
2021-09-08  3:29   ` Li Wang
2021-09-08  3:29     ` 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.