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

1.2     ! bsiegert    1: $NetBSD: patch-src_subshell_common.c,v 1.1 2016/12/16 00:02:28 joerg 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.2     ! bsiegert    6: --- src/subshell/common.c.orig 2018-12-28 19:35:25.000000000 +0000
1.1       joerg       7: +++ src/subshell/common.c
1.2     ! bsiegert    8: @@ -317,6 +317,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? */
                     14:          init_file = mc_config_get_full_path ("ashrc");
                     15:  
1.2     ! bsiegert   16: @@ -510,7 +511,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.2     ! bsiegert   25: @@ -565,19 +566,20 @@ feed_subshell (int how, gboolean fail_on
1.1       joerg      26:              /* for (i=0; i<5; ++i)  * FIXME -- experimental */
                     27:          {
                     28:              bytes = read (mc_global.tty.subshell_pty, pty_buffer, sizeof (pty_buffer));
                     29: +            serrno = errno;
                     30:  
                     31:              /* The subshell has died */
                     32: -            if (bytes == -1 && errno == EIO && !subshell_alive)
                     33: +            if (((bytes == -1 && errno == EIO) || bytes == 0) && !subshell_alive)
                     34:                  return FALSE;
                     35:  
                     36: -            if (bytes <= 0)
                     37: +            if (bytes < 0)
                     38:              {
1.2     ! bsiegert   39:  #ifdef PTY_ZEROREAD
        !            40:                  /* On IBM i, read(1) can return 0 for a non-closed fd */
        !            41:                  continue;
        !            42:  #else
1.1       joerg      43:                  tcsetattr (STDOUT_FILENO, TCSANOW, &shell_mode);
                     44: -                fprintf (stderr, "read (subshell_pty...): %s\r\n", unix_error_string (errno));
                     45: +                fprintf (stderr, "read (subshell_pty...): %s\r\n", unix_error_string (serrno));
                     46:                  exit (EXIT_FAILURE);
1.2     ! bsiegert   47:  #endif
1.1       joerg      48:              }

CVSweb <webmaster@jp.NetBSD.org>