diff mbox series

答复: [PATCH] openposix/fork/11-1.c: Clean up temporary file

Message ID F3D3F6AC3820BB4C9FCA340DB5C32CB40386FA88@dggeml531-mbx.china.huawei.com
State Superseded
Headers show
Series 答复: [PATCH] openposix/fork/11-1.c: Clean up temporary file | expand

Commit Message

Zhao Gongyi Feb. 19, 2021, 9:34 a.m. UTC
Hi Li,

I think we need to delete the tempfile after the testing(in the cleanup phase).

In this case, we just hope that call unlink after open/mkstemp since unlink would not destroy the inode,

so call unlink before fork would not affect the test?

发件人: Li Wang [mailto:liwang@redhat.com]
发送时间: 2021年2月19日 15:45
收件人: zhaogongyi <zhaogongyi@huawei.com>
抄送: LTP List <ltp@lists.linux.it>
主题: Re: [LTP] [PATCH] openposix/fork/11-1.c: Clean up temporary file

Hi Gongyi,

On Fri, Feb 19, 2021 at 1:05 PM zhao gongyi <zhaogongyi@huawei.com<mailto:zhaogongyi@huawei.com>> wrote:
We need to clean up temporary file /tmp/fork-11-1-XXXXXX which created by mkstemp.

Signed-off-by: zhao gongyi <zhaogongyi@huawei.com<mailto:zhaogongyi@huawei.com>>
---
 .../open_posix_testsuite/conformance/interfaces/fork/11-1.c     | 2 ++
 1 file changed, 2 insertions(+)

BTW, seems the child report a wrong status of the locked file, while
fcntl(fd, F_SETLK, &fl) return -1 and sets errno to EACCES or EAGAIN,
shouldn't that mean the file already been locked by the parent?


+
        if (fcntl(fd, F_SETLK, &fl) == -1) {
                printf("Could not set initial lock: %s (%d)\n",
                       strerror(errno), errno);
--
2.17.1


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


--
Regards,
Li Wang

Comments

Li Wang Feb. 19, 2021, 1:38 p.m. UTC | #1
On Fri, Feb 19, 2021 at 5:34 PM zhaogongyi <zhaogongyi@huawei.com> wrote:

> Hi Li,
>
>
>
> I think we need to delete the tempfile after the testing(in the cleanup
> phase).
>
>
>
> In this case, we just hope that call unlink after open/mkstemp since
> unlink would not destroy the inode,
>
>
>
> so call unlink before fork would not affect the test?
>

Right, but better to put behind of close(fd) that makes logic more clear.


>
> BTW, seems the child report a wrong status of the locked file, while
>
> fcntl(fd, F_SETLK, &fl) return -1 and sets errno to EACCES or EAGAIN,
>
> shouldn't that mean the file already been locked by the parent?
>

And what do u think about this?
diff mbox series

Patch

diff --git a/testcases/open_posix_testsuite/conformance/interfaces/fork/11-1.c b/testcases/open_posix_testsuite/conformance/interfaces/fork/11-1.c
index a43bc274c..e9b18958c 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/fork/11-1.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/fork/11-1.c
@@ -79,6 +79,8 @@  int main(void)
                return result;
        }

+       unlink(path_template);

Why do we need to delete the tempfile before acquiring a lock?
Or did you mean doing this after the testing(in the cleanup phase).