[Libguestfs] [libnbd PATCH v3 10/19] CONNECT_COMMAND.START: use symbolic constants for fd#0 and fd#1

Laszlo Ersek lersek at redhat.com
Thu Mar 23 12:10:07 UTC 2023


Refer to fd#0 and fd#1 with the symbolic constants STDIN_FILENO and
STDOUT_FILENO from <unistd.h>, for better readability.

Signed-off-by: Laszlo Ersek <lersek at redhat.com>
Reviewed-by: Richard W.M. Jones <rjones at redhat.com>
---

Notes:
    v4:
    
    - pick up Rich's R-b

 generator/states-connect.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/generator/states-connect.c b/generator/states-connect.c
index 2fd7429ae056..5612da53f59f 100644
--- a/generator/states-connect.c
+++ b/generator/states-connect.c
@@ -260,11 +260,11 @@  CONNECT_COMMAND.START:
     return 0;
   }
   if (pid == 0) {         /* child - run command */
-    close (0);
-    close (1);
+    close (STDIN_FILENO);
+    close (STDOUT_FILENO);
     close (sv[0]);
-    dup2 (sv[1], 0);
-    dup2 (sv[1], 1);
+    dup2 (sv[1], STDIN_FILENO);
+    dup2 (sv[1], STDOUT_FILENO);
     close (sv[1]);
 
     /* Restore SIGPIPE back to SIG_DFL. */



More information about the Libguestfs mailing list