qemu-block
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH for-5.2 05/10] vhost-user-blk-test: close fork child file des


From: Coiby Xu
Subject: Re: [PATCH for-5.2 05/10] vhost-user-blk-test: close fork child file descriptors
Date: Tue, 24 Nov 2020 20:08:26 +0800

Hi Stefan,

On Wed, Nov 11, 2020 at 12:43:26PM +0000, Stefan Hajnoczi wrote:
Do not leave stdin and stdout open after fork. stdout is the
tap-driver.pl pipe. If we keep the pipe open then tap-driver.pl will not
detect that qos-test has terminated and it will hang.

I wonder under which situation this would happen. I couldn't re-produce
this issue locally.


Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
tests/qtest/vhost-user-blk-test.c | 9 +++++++++
1 file changed, 9 insertions(+)

diff --git a/tests/qtest/vhost-user-blk-test.c 
b/tests/qtest/vhost-user-blk-test.c
index f05f14c192..4019a72ac0 100644
--- a/tests/qtest/vhost-user-blk-test.c
+++ b/tests/qtest/vhost-user-blk-test.c
@@ -749,6 +749,15 @@ static char *start_vhost_user_blk(GString *cmd_line, int 
vus_instances,
                   storage_daemon_command->str);
    pid_t pid = fork();
    if (pid == 0) {
+        /*
+         * Close standard file descriptors so tap-driver.pl pipe detects when
+         * our parent terminates.
+         */
+        close(0);
+        close(1);
+        open("/dev/null", O_RDONLY);
+        open("/dev/null", O_WRONLY);
+
        execlp("/bin/sh", "sh", "-c", storage_daemon_command->str, NULL);
        exit(1);
    }
--
2.28.0


--
Best regards,
Coiby



reply via email to

[Prev in Thread] Current Thread [Next in Thread]