From 4da6ea8db3a14db5ac76a0d468290d46a857a1d4 Mon Sep 17 00:00:00 2001 From: "Jesse R. Gorzinski" Date: Tue, 4 Sep 2018 11:57:11 +0300 Subject: [PATCH] (feed_subshell): on IBM i, read(1) can return 0 for a non-closed fd. Signed-off-by: Andrew Borodin --- configure.ac | 5 +++++ src/subshell/common.c | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/configure.ac b/configure.ac index 9680a694d..cdf5a8b6c 100644 --- a/configure.ac +++ b/configure.ac @@ -321,6 +321,11 @@ case $host_os in ;; esac +case $host_os in +*os400) + AC_DEFINE([PTY_ZEROREAD], [1], [read(1) can return 0 for a non-closed fd]) +esac + dnl Check linux/fs.h for FICLONE to support BTRFS's file clone operation case $host_os in linux*) diff --git a/src/subshell/common.c b/src/subshell/common.c index eca94311e..505fbe325 100644 --- a/src/subshell/common.c +++ b/src/subshell/common.c @@ -558,9 +558,14 @@ feed_subshell (int how, gboolean fail_on_error) if (bytes <= 0) { +#ifdef PTY_ZEROREAD + /* On IBM i, read(1) can return 0 for a non-closed fd */ + continue; +#else tcsetattr (STDOUT_FILENO, TCSANOW, &shell_mode); fprintf (stderr, "read (subshell_pty...): %s\r\n", unix_error_string (errno)); exit (EXIT_FAILURE); +#endif } if (how == VISIBLY)