[LTP] [PATCH] open_posix: Add failure handling of fork()
zhaogongyi
zhaogongyi@huawei.com
Thu Sep 23 09:49:16 CEST 2021
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20210923/c4e2d0d0/attachment-0001.htm>
More information about the ltp
mailing list