Subject: Re: bug#19191: 24.4; su command in *shell* buffer does not work

From: 白井彰 <[email-masked]>
Date: Fri, 3 Apr 2015 01:56:57 +0900

Today I tried what you had suggested, but I could not find significant
differences.

% grep '#.*PTY' emacs-24.3/src/config.h > /tmp/config.h_PTY_emacs-24.3
% grep '#.*PTY' emacs-24.4/src/config.h > /tmp/config.h_PTY_emacs-24.4

% cat /tmp/config.h_PTY_emacs-24.3
/* #undef BROKEN_PTY_READ_AFTER_EAGAIN */
/* #undef DONT_REOPEN_PTY */
#define FIRST_PTY_LETTER 'z'
#define HAVE_PTYS 1
/* #undef HAVE_PTY_H */
/* #undef PTY_ITERATION */
#define PTY_NAME_SPRINTF strcpy (pty_name, "/dev/ptmx");
/* #undef PTY_OPEN */
#define PTY_TTY_NAME_SPRINTF { char *ptsname (int), *ptyname; int grantpt_result; sigset_t blocked; sigemptyset (&blocked); sigaddset (&blocked, SIGCLD); pthread_sigmask (SIG_BLOCK, &blocked, 0); grantpt_result = grantpt (fd); pthread_sigmask (SIG_UNBLOCK, &blocked, 0); if (grantpt_result == -1 || unlockpt (fd) == -1 || !(ptyname = ptsname (fd))) { emacs_close (fd); return -1; } snprintf (pty_name, sizeof pty_name, "%s", ptyname); }
#define SETUP_SLAVE_PTY if (ioctl (xforkin, I_PUSH, "ptem") == -1) fatal ("ioctl I_PUSH ptem"); if (ioctl (xforkin, I_PUSH, "ldterm") == -1) fatal ("ioctl I_PUSH ldterm"); if (ioctl (xforkin, I_PUSH, "ttcompat") == -1) fatal ("ioctl I_PUSH ttcompat");
/* #undef UNIX98_PTYS */

% cat /tmp/config.h_PTY_emacs-24.4
/* #undef BROKEN_PTY_READ_AFTER_EAGAIN */
/* #undef DONT_REOPEN_PTY */
#define FIRST_PTY_LETTER 'z'
#define HAVE_PTYS 1
/* #undef HAVE_PTY_H */
/* #undef PTY_ITERATION */
#define PTY_NAME_SPRINTF strcpy (pty_name, "/dev/ptmx");
/* #undef PTY_OPEN */
#define PTY_TTY_NAME_SPRINTF { char *ptsname (int), *ptyname; int grantpt_result; sigset_t blocked; sigemptyset (&blocked); sigaddset (&blocked, SIGCHLD); pthread_sigmask (SIG_BLOCK, &blocked, 0); grantpt_result = grantpt (fd); pthread_sigmask (SIG_UNBLOCK, &blocked, 0); if (grantpt_result == -1 || unlockpt (fd) == -1 || !(ptyname = ptsname (fd))) { emacs_close (fd); return -1; } snprintf (pty_name, PTY_NAME_SIZE, "%s", ptyname); }
#define SETUP_SLAVE_PTY if (ioctl (xforkin, I_PUSH, "ptem") == -1) fatal ("ioctl I_PUSH ptem"); if (ioctl (xforkin, I_PUSH, "ldterm") == -1) fatal ("ioctl I_PUSH ldterm"); if (ioctl (xforkin, I_PUSH, "ttcompat") == -1) fatal ("ioctl I_PUSH ttcompat");
/* #undef UNIX98_PTYS */

% diff /tmp/config.h_PTY_emacs-24.3 /tmp/config.h_PTY_emacs-24.4
9c9
< #define PTY_TTY_NAME_SPRINTF { char *ptsname (int), *ptyname; int grantpt_result; sigset_t blocked; sigemptyset (&blocked); sigaddset (&blocked, SIGCLD); pthread_sigmask (SIG_BLOCK, &blocked, 0); grantpt_result = grantpt (fd); pthread_sigmask (SIG_UNBLOCK, &blocked, 0); if (grantpt_result == -1 || unlockpt (fd) == -1 || !(ptyname = ptsname (fd))) { emacs_close (fd); return -1; } snprintf (pty_name, sizeof pty_name, "%s", ptyname); }
---
> #define PTY_TTY_NAME_SPRINTF { char *ptsname (int), *ptyname; int grantpt_result; sigset_t blocked; sigemptyset (&blocked); sigaddset (&blocked, SIGCHLD); pthread_sigmask (SIG_BLOCK, &blocked, 0); grantpt_result = grantpt (fd); pthread_sigmask (SIG_UNBLOCK, &blocked, 0); if (grantpt_result == -1 || unlockpt (fd) == -1 || !(ptyname = ptsname (fd))) { emacs_close (fd); return -1; } snprintf (pty_name, PTY_NAME_SIZE, "%s", ptyname); }

% cat /tmp/config.h_PTY_emacs-24.3 | grep PTY_TTY_NAME_SPRINTF | sed 's/#define//' | indent -st > /tmp/config.h_PTY_emacs-24.3_indent-st
% cat /tmp/config.h_PTY_emacs-24.4 | grep PTY_TTY_NAME_SPRINTF | sed 's/#define//' | indent -st > /tmp/config.h_PTY_emacs-24.4_indent-st
% diff /tmp/config.h_PTY_emacs-24.3_indent-st /tmp/config.h_PTY_emacs-24.4_indent-st
6c6
<       sigaddset(&blocked, SIGCLD);
---
>       sigaddset(&blocked, SIGCHLD);
13c13
<       } snprintf(pty_name, sizeof pty_name, "%s", ptyname);
---
>       } snprintf(pty_name, PTY_NAME_SIZE, "%s", ptyname);

And I replaced the definition of PTY_TTY_NAME_SPRINTF in
emacs-24.4/src/config.h with the definition of PTY_TTY_NAME_SPRINTF in
emacs-24.3/src/config.h and typed "make" and "emacs -Q", the emacs
(almost emacs-24.4 except PTY_TTY_NAME_SPRINTF) still said "Warning:
no access to tty; thus no job control in this shell...".

> 2015/04/01 22:49、Wolfgang Jenkner <[email-masked]> のメール：
> 
>