Annotation of pkgsrc/sysutils/mc/patches/patch-src_subshell_common.c, revision 1.3

1.3     ! nia         1: $NetBSD: patch-src_subshell_common.c,v 1.2 2019/01/18 22:28:38 bsiegert Exp $
1.1       joerg       2: 
                      3: Report error from read since tcsetattr can replace errno.
                      4: Recognize /bin/sh as valid shell and don't complain about it.
                      5: 
1.3     ! nia         6: --- src/subshell/common.c.orig 2021-08-01 16:45:58.000000000 +0000
1.1       joerg       7: +++ src/subshell/common.c
1.3     ! nia         8: @@ -345,6 +345,7 @@ init_subshell_child (const char *pty_nam
1.1       joerg       9:  
                     10:      case SHELL_ASH_BUSYBOX:
                     11:      case SHELL_DASH:
                     12: +    case SHELL_SH:
                     13:          /* Do we have a custom init file ~/.local/share/mc/ashrc? */
1.3     ! nia        14:          init_file = mc_config_get_full_path (MC_ASHRC_FILE);
1.1       joerg      15:  
1.3     ! nia        16: @@ -740,7 +741,7 @@ static gboolean
1.1       joerg      17:  feed_subshell (int how, gboolean fail_on_error)
                     18:  {
                     19:      fd_set read_set;            /* For 'select' */
                     20: -    int bytes;                  /* For the return value from 'read' */
                     21: +    int serrno, bytes;                  /* For the return value from 'read' */
                     22:      int i;                      /* Loop counter */
                     23:  
                     24:      struct timeval wtime;       /* Maximum time we wait for the subshell */
1.3     ! nia        25: @@ -774,6 +775,7 @@ feed_subshell (int how, gboolean fail_on
        !            26:  
        !            27:          if (select (maxfdp + 1, &read_set, NULL, NULL, wptr) == -1)
        !            28:          {
        !            29: +            serrno = errno;
        !            30:              /* Despite using SA_RESTART, we still have to check for this */
        !            31:              if (errno == EINTR)
        !            32:              {
        !            33: @@ -784,7 +786,7 @@ feed_subshell (int how, gboolean fail_on
        !            34:              }
        !            35:              tcsetattr (STDOUT_FILENO, TCSANOW, &shell_mode);
        !            36:              fprintf (stderr, "select (FD_SETSIZE, &read_set...): %s\r\n",
        !            37: -                     unix_error_string (errno));
        !            38: +                     unix_error_string (serrno));
        !            39:              exit (EXIT_FAILURE);
        !            40:          }
        !            41:  
        !            42: @@ -797,19 +799,20 @@ feed_subshell (int how, gboolean fail_on
1.1       joerg      43:              /* for (i=0; i<5; ++i)  * FIXME -- experimental */
                     44:          {
                     45:              bytes = read (mc_global.tty.subshell_pty, pty_buffer, sizeof (pty_buffer));
                     46: +            serrno = errno;
                     47:  
                     48:              /* The subshell has died */
                     49: -            if (bytes == -1 && errno == EIO && !subshell_alive)
                     50: +            if (((bytes == -1 && errno == EIO) || bytes == 0) && !subshell_alive)
                     51:                  return FALSE;
                     52:  
                     53: -            if (bytes <= 0)
                     54: +            if (bytes < 0)
                     55:              {
1.2       bsiegert   56:  #ifdef PTY_ZEROREAD
                     57:                  /* On IBM i, read(1) can return 0 for a non-closed fd */
                     58:                  continue;
                     59:  #else
1.1       joerg      60:                  tcsetattr (STDOUT_FILENO, TCSANOW, &shell_mode);
                     61: -                fprintf (stderr, "read (subshell_pty...): %s\r\n", unix_error_string (errno));
                     62: +                fprintf (stderr, "read (subshell_pty...): %s\r\n", unix_error_string (serrno));
                     63:                  exit (EXIT_FAILURE);
1.2       bsiegert   64:  #endif
1.1       joerg      65:              }
1.3     ! nia        66: @@ -827,9 +830,10 @@ feed_subshell (int how, gboolean fail_on
        !            67:              bytes = read (subshell_pipe[READ], subshell_cwd, sizeof (subshell_cwd));
        !            68:              if (bytes <= 0)
        !            69:              {
        !            70: +                serrno = errno;
        !            71:                  tcsetattr (STDOUT_FILENO, TCSANOW, &shell_mode);
        !            72:                  fprintf (stderr, "read (subshell_pipe[READ]...): %s\r\n",
        !            73: -                         unix_error_string (errno));
        !            74: +                         unix_error_string (serrno));
        !            75:                  exit (EXIT_FAILURE);
        !            76:              }
        !            77:  
        !            78: @@ -854,9 +858,10 @@ feed_subshell (int how, gboolean fail_on
        !            79:              bytes = read (STDIN_FILENO, pty_buffer, sizeof (pty_buffer));
        !            80:              if (bytes <= 0)
        !            81:              {
        !            82: +                serrno = errno;
        !            83:                  tcsetattr (STDOUT_FILENO, TCSANOW, &shell_mode);
        !            84:                  fprintf (stderr,
        !            85: -                         "read (STDIN_FILENO, pty_buffer...): %s\r\n", unix_error_string (errno));
        !            86: +                         "read (STDIN_FILENO, pty_buffer...): %s\r\n", unix_error_string (serrno));
        !            87:                  exit (EXIT_FAILURE);
        !            88:              }
        !            89:  

CVSweb <webmaster@jp.NetBSD.org>