From unknown Mon Aug 18 22:11:46 2025 X-Loop: help-debbugs@gnu.org Subject: bug#20555: Emacs 24.2 vs 24.4 on Solaris: M-x shell and "tty => not a tty" Resent-From: Paul Eggert Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 12 May 2015 06:09:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 20555 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: gko@gko.net, 20555@debbugs.gnu.org X-Debbugs-Original-To: Georges Ko , Emacs bug reports and feature requests Received: via spool by submit@debbugs.gnu.org id=B.1431410938985 (code B ref -1); Tue, 12 May 2015 06:09:02 +0000 Received: (at submit) by debbugs.gnu.org; 12 May 2015 06:08:58 +0000 Received: from localhost ([127.0.0.1]:41451 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Ys3NB-0000Fo-2P for submit@debbugs.gnu.org; Tue, 12 May 2015 02:08:57 -0400 Received: from eggs.gnu.org ([208.118.235.92]:33069) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Ys3N9-0000FZ-1t for submit@debbugs.gnu.org; Tue, 12 May 2015 02:08:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ys3N2-0007G1-Li for submit@debbugs.gnu.org; Tue, 12 May 2015 02:08:49 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50 autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:59399) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ys3N2-0007Fx-IO for submit@debbugs.gnu.org; Tue, 12 May 2015 02:08:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46575) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ys3N1-0002BG-Dc for bug-gnu-emacs@gnu.org; Tue, 12 May 2015 02:08:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ys3My-0007DN-2e for bug-gnu-emacs@gnu.org; Tue, 12 May 2015 02:08:47 -0400 Received: from smtp.cs.ucla.edu ([131.179.128.62]:58390) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ys3Mx-0007CK-Sw for bug-gnu-emacs@gnu.org; Tue, 12 May 2015 02:08:44 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id 06761A6000D; Mon, 11 May 2015 23:08:36 -0700 (PDT) X-Virus-Scanned: amavisd-new at smtp.cs.ucla.edu Received: from smtp.cs.ucla.edu ([127.0.0.1]) by localhost (smtp.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id mXhajxLxlkKT; Mon, 11 May 2015 23:08:35 -0700 (PDT) Received: from [192.168.1.9] (pool-100-32-155-148.lsanca.fios.verizon.net [100.32.155.148]) by smtp.cs.ucla.edu (Postfix) with ESMTPSA id EE6A1A6000C; Mon, 11 May 2015 23:08:34 -0700 (PDT) Message-ID: <555198E2.30809@cs.ucla.edu> Date: Mon, 11 May 2015 23:08:34 -0700 From: Paul Eggert Organization: UCLA Computer Science Department User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 MIME-Version: 1.0 References: <86twvjjj2c.fsf@gko.net> In-Reply-To: <86twvjjj2c.fsf@gko.net> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.0 (----) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.0 (----) [moving this to bug-gnu-emacs, so that it gets a proper bug number] Georges Ko wrote: > What were the changes done on Emacs 24.4 regarding subshells (or > processes), compared to version 24.2? Quite a few, I suspect. You can use 'diff' to find out the details.... > When compiled in the same environment, "tty" in a subshell > (M-x shell) has different outputs: > > - in Emacs 24.2, "tty" outputs the tty, > - in Emacs 24.4, "tty" outputs "not a tty". > > That is, if I run the command below to spawn a shell: > > (apply 'start-process "shell" "*shell*" "/bin/ksh" '("-i")) > > - in Emacs 24.2, "ps" shows the shell has a normal tty, > - in Emacs 24.4, "ps" shows the shell has a tty with "?". I don't observe either problem when running Emacs 24.5 under Solaris 11 x86-64 compiled with the bundled GCC (4.5.2). However, I do observe them when running Emacs 24.5 under Solaris 10 sparc compiled with Sun C 5.13. > I couldn't compile 24.3 due to some errors, so I don't know its behavior. Emacs 24.3 is bundled within Solaris 11.2, for what it's worth. If you're still running into problems, I suggest replying with details of how you built Emacs (version of OS and compiler, 'configure' arguments, log from 'configure' and 'make', etc.). PS. This looks a bit like Bug#9150 , but that bug was in an older Emacs, which probably means it's independent. From unknown Mon Aug 18 22:11:46 2025 X-Loop: help-debbugs@gnu.org Subject: bug#20555: Emacs 24.2 vs 24.4 on Solaris: M-x shell and "tty => not a tty" Resent-From: Glenn Morris Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 12 May 2015 06:37:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 20555 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Paul Eggert Cc: 20555@debbugs.gnu.org, gko@gko.net Received: via spool by 20555-submit@debbugs.gnu.org id=B20555.14314125683663 (code B ref 20555); Tue, 12 May 2015 06:37:01 +0000 Received: (at 20555) by debbugs.gnu.org; 12 May 2015 06:36:08 +0000 Received: from localhost ([127.0.0.1]:41469 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Ys3nT-0000x1-Dk for submit@debbugs.gnu.org; Tue, 12 May 2015 02:36:07 -0400 Received: from fencepost.gnu.org ([208.118.235.10]:45589 ident=Debian-exim) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Ys3nQ-0000ws-2m for 20555@debbugs.gnu.org; Tue, 12 May 2015 02:36:04 -0400 Received: from rgm by fencepost.gnu.org with local (Exim 4.71) (envelope-from ) id 1Ys3nN-0001yj-GN; Tue, 12 May 2015 02:36:01 -0400 From: Glenn Morris References: <86twvjjj2c.fsf@gko.net> <555198E2.30809@cs.ucla.edu> X-Spook: blackjack pink noise munitions Agfa Elvis Vickie Weaver X-Ran: x^#[{=7nLf`kNOxe;xc2hPs`ScGjA-T.7-\ZnFK%O48k:rj](|+*b\W.I|@:aG-Opx%tSu X-Hue: cyan X-Attribution: GM Date: Tue, 12 May 2015 02:36:01 -0400 In-Reply-To: <555198E2.30809@cs.ucla.edu> (Paul Eggert's message of "Mon, 11 May 2015 23:08:34 -0700") Message-ID: User-Agent: Gnus (www.gnus.org), GNU Emacs (www.gnu.org/software/emacs/) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Spam-Score: -5.0 (-----) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) Paul Eggert wrote: > [moving this to bug-gnu-emacs, so that it gets a proper bug number] It already has one: http://debbugs.gnu.org/19191 From debbugs-submit-bounces@debbugs.gnu.org Tue May 12 02:37:13 2015 Received: (at control) by debbugs.gnu.org; 12 May 2015 06:37:13 +0000 Received: from localhost ([127.0.0.1]:41473 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Ys3oX-0000zA-5O for submit@debbugs.gnu.org; Tue, 12 May 2015 02:37:13 -0400 Received: from fencepost.gnu.org ([208.118.235.10]:45609 ident=Debian-exim) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Ys3oV-0000z1-Dm for control@debbugs.gnu.org; Tue, 12 May 2015 02:37:11 -0400 Received: from rgm by fencepost.gnu.org with local (Exim 4.71) (envelope-from ) id 1Ys3oV-00035F-7m for control@debbugs.gnu.org; Tue, 12 May 2015 02:37:11 -0400 Date: Tue, 12 May 2015 02:37:11 -0400 Message-Id: Subject: control message for bug 20555 To: X-Mailer: mail (GNU Mailutils 2.1) From: Glenn Morris X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) merge 19191 20555 From unknown Mon Aug 18 22:11:46 2025 X-Loop: help-debbugs@gnu.org Subject: bug#20555: Emacs 24.2 vs 24.4 on Solaris: M-x shell and "tty => not a tty" In-Reply-To: <555198E2.30809@cs.ucla.edu> Resent-From: Georges Ko Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 13 May 2015 15:23:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 20555 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 20555@debbugs.gnu.org Cc: okshirai@gmail.com X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.14315305604858 (code B ref -1); Wed, 13 May 2015 15:23:02 +0000 Received: (at submit) by debbugs.gnu.org; 13 May 2015 15:22:40 +0000 Received: from localhost ([127.0.0.1]:43919 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YsYUX-0001G9-HN for submit@debbugs.gnu.org; Wed, 13 May 2015 11:22:39 -0400 Received: from eggs.gnu.org ([208.118.235.92]:42071) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YsUwe-0003Qk-R2 for submit@debbugs.gnu.org; Wed, 13 May 2015 07:35:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YsUwW-0000wX-7S for submit@debbugs.gnu.org; Wed, 13 May 2015 07:35:19 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-0.3 required=5.0 tests=BAYES_00,DATE_IN_PAST_03_06 autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:48420) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YsUwW-0000wP-4Y for submit@debbugs.gnu.org; Wed, 13 May 2015 07:35:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55523) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YsUwQ-0005Je-CK for bug-gnu-emacs@gnu.org; Wed, 13 May 2015 07:35:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YsUwN-0000qQ-1s for bug-gnu-emacs@gnu.org; Wed, 13 May 2015 07:35:10 -0400 Received: from plane.gmane.org ([80.91.229.3]:40347) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YsUwM-0000iy-Q4 for bug-gnu-emacs@gnu.org; Wed, 13 May 2015 07:35:06 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1YsUwI-0002at-Fk for bug-gnu-emacs@gnu.org; Wed, 13 May 2015 13:35:02 +0200 Received: from 223-136-127-143.emome-ip.hinet.net ([223.136.127.143]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 13 May 2015 13:35:02 +0200 Received: from gko by 223-136-127-143.emome-ip.hinet.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 13 May 2015 13:35:02 +0200 X-Injected-Via-Gmane: http://gmane.org/ From: Georges Ko Date: Wed, 13 May 2015 15:12:32 +0800 Organization: gko.net Lines: 60 Message-ID: References: <86twvjjj2c.fsf@gko.net> <555198E2.30809@cs.ucla.edu> Mime-Version: 1.0 Content-Type: text/plain X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 223-136-127-143.emome-ip.hinet.net User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (windows-nt) Hamster/2.0.0.1 Cancel-Lock: sha1:4VuxjvTxEu1ZYAsKxjigEtlwerc= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -3.0 (---) X-Mailman-Approved-At: Wed, 13 May 2015 11:22:35 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.0 (---) Glenn Morris writes: > Paul Eggert wrote: > >> [moving this to bug-gnu-emacs, so that it gets a proper bug number] > > It already has one: http://debbugs.gnu.org/19191 I have been able to "fix" the problem by trial and error. On my system, the function allocate_pty (process.c) calls the macro PTY_TTY_NAME_SPRINTF, generated in config.h, which is: #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); } It turned out that grantpt(fd) returns -1, with errno = 13 (EACCES), so -1 is returned by allocate_pty. After checking EACCES of grantpt(): The slave pseudoterminal was opened before grantpt(), or a grantpt() was already issued. In either case, slave pseudoterminal permissions and ownership have already been updated. If you use grantpt() to change slave pseudoterminal permissions, you must issue grantpt() between the master open and the first pseudoterminal open, and grantpt() can only be issued once. I changed the macro to: if ( /* grantpt_result == -1 || */ unlockpt (fd) == -1 || !(ptyname = ptsname (fd))) and it "fixed" the problem. I'll let the experts figure out the root cause... The diff of configure (24.5): $ diff configure.24.5 configure.24.5.ttyfix 17105c17105 < $as_echo "#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); }" >>confdefs.h --- > $as_echo "#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); }" >>confdefs.h Georges -- Georges Ko gko@gko.net 2015-05-13 From debbugs-submit-bounces@debbugs.gnu.org Thu May 28 16:16:17 2015 Received: (at control) by debbugs.gnu.org; 28 May 2015 20:16:17 +0000 Received: from localhost ([127.0.0.1]:59824 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Yy4Dx-0006es-2L for submit@debbugs.gnu.org; Thu, 28 May 2015 16:16:17 -0400 Received: from fencepost.gnu.org ([208.118.235.10]:35210 ident=Debian-exim) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Yy4Du-0006ek-Jx for control@debbugs.gnu.org; Thu, 28 May 2015 16:16:14 -0400 Received: from rgm by fencepost.gnu.org with local (Exim 4.71) (envelope-from ) id 1Yy4Du-0007bZ-5j for control@debbugs.gnu.org; Thu, 28 May 2015 16:16:14 -0400 Date: Thu, 28 May 2015 16:16:14 -0400 Message-Id: Subject: control message for bug 20686 To: X-Mailer: mail (GNU Mailutils 2.1) From: Glenn Morris X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) merge 19191 20686 From debbugs-submit-bounces@debbugs.gnu.org Thu May 28 16:17:30 2015 Received: (at control) by debbugs.gnu.org; 28 May 2015 20:17:30 +0000 Received: from localhost ([127.0.0.1]:59828 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Yy4F7-0006h2-Jf for submit@debbugs.gnu.org; Thu, 28 May 2015 16:17:29 -0400 Received: from fencepost.gnu.org ([208.118.235.10]:35252 ident=Debian-exim) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Yy4F6-0006gv-51 for control@debbugs.gnu.org; Thu, 28 May 2015 16:17:28 -0400 Received: from rgm by fencepost.gnu.org with local (Exim 4.71) (envelope-from ) id 1Yy4F5-00080z-VS for control@debbugs.gnu.org; Thu, 28 May 2015 16:17:28 -0400 Date: Thu, 28 May 2015 16:17:27 -0400 Message-Id: Subject: control message for bug 19759 To: X-Mailer: mail (GNU Mailutils 2.1) From: Glenn Morris X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) block 19759 by 20555 From unknown Mon Aug 18 22:11:46 2025 X-Loop: help-debbugs@gnu.org Subject: bug#20555: Emacs 24.2 vs 24.4 on Solaris: M-x shell and "tty => not a tty" References: <555198E2.30809@cs.ucla.edu> In-Reply-To: <555198E2.30809@cs.ucla.edu> Resent-From: =?UTF-8?Q?=E7=99=BD=E4=BA=95=E5=BD=B0?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 01 Jun 2015 16:54:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 20555 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 20555@debbugs.gnu.org Cc: Akira Shirai Received: via spool by 20555-submit@debbugs.gnu.org id=B20555.143317760716729 (code B ref 20555); Mon, 01 Jun 2015 16:54:02 +0000 Received: (at 20555) by debbugs.gnu.org; 1 Jun 2015 16:53:27 +0000 Received: from localhost ([127.0.0.1]:36348 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YzSxq-0004Ll-5Q for submit@debbugs.gnu.org; Mon, 01 Jun 2015 12:53:26 -0400 Received: from mail-pd0-f195.google.com ([209.85.192.195]:33494) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YzSxn-0004LX-OE for 20555@debbugs.gnu.org; Mon, 01 Jun 2015 12:53:24 -0400 Received: by pdjp10 with SMTP id p10so17644092pdj.0 for <20555@debbugs.gnu.org>; Mon, 01 Jun 2015 09:53:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:content-type:content-transfer-encoding:subject:date:message-id :cc:to:mime-version; bh=nwlakbCclbNu6eMkC+kbmZDl+qKrXALaOQxKEFpJefE=; b=rnaaV1H30QF+107QuHYv2heiptWunFIlIsv22MkkEBJUHsTOo3PcBkA5dpkITXPdYL e7MNWckmMhpZGpONHj1AESAAy6NJP04URiDshL3gVPehEPBxotWU71DT8UQxZyVpKUzT AzpgFCLk+EORIFv52/rQ1a9XND4+SdZ4R+E+aF/1zJ0dwODqd2ILlmaV0qNjKFYfDoRl icchBPkXGsfWeHB1hlq/nglKcncEw6fOQXz3DfSKBA5v5gW+2Kweve4sepjnvOxCuC7u ovHC/Vazks22wNe7vZDLaQBk3uMsqdKv9J0xpniIvCpSuMJ/svMjCe3sOeKzhhIHbVcl zjQQ== X-Received: by 10.70.140.38 with SMTP id rd6mr41866612pdb.47.1433177597762; Mon, 01 Jun 2015 09:53:17 -0700 (PDT) Received: from [172.20.10.11] (pw126254132031.8.panda-world.ne.jp. [126.254.132.31]) by mx.google.com with ESMTPSA id zt9sm15095210pac.9.2015.06.01.09.53.14 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 01 Jun 2015 09:53:16 -0700 (PDT) From: =?UTF-8?Q?=E7=99=BD=E4=BA=95=E5=BD=B0?= Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Date: Tue, 2 Jun 2015 01:53:12 +0900 Message-Id: <9051A319-D257-400F-B74E-C46B2C14D8F3@gmail.com> Mime-Version: 1.0 (Mac OS X Mail 8.2 \(2098\)) X-Mailer: Apple Mail (2.2098) X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) I wrote a small program my-emacs-24.5.c, and found that grantpt(fd) returned -1 after fcntl(fd, F_SETFD, FD_CLOEXEC). Without fcntl(fd, F_SETFD, FD_CLOEXEC), grantpt(fd) returns 0. aaa% sh emacs-24.5/build-aux/config.guess i386-pc-solaris2.10 aaa% ls my-emacs-24.5.c my-emacs-24.5.c aaa% make my-emacs-24.5 && ./my-emacs-24.5 cc -o my-emacs-24.5 my-emacs-24.5.c call_fcntl_fd_cloexec: 1 fcntl_result: 0 fd: 3 grantpt_result: -1 errno: 13 grantpt: Permission denied aaa% make my-emacs-24.5 && ./my-emacs-24.5 call_fcntl_fd_cloexec=3D0 `my-emacs-24.5' is up to date. call_fcntl_fd_cloexec: 0 fd: 3 grantpt_result: 0 bbb% sh emacs-24.5/build-aux/config.guess sparc-sun-solaris2.8 bbb% rm my-emacs-24.5 bbb% make my-emacs-24.5 && ./my-emacs-24.5 cc -o my-emacs-24.5 my-emacs-24.5.c call_fcntl_fd_cloexec: 1 fcntl_result: 0 fd: 3 grantpt_result: -1 errno: 0 grantpt: Error 0 bbb% make my-emacs-24.5 && ./my-emacs-24.5 call_fcntl_fd_cloexec=3D0 `my-emacs-24.5' is up to date. call_fcntl_fd_cloexec: 0 fd: 3 grantpt_result: 0 % cat -n my-emacs-24.5.c 1 /* 24.5 */ 2 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9 #include 10 #include 11 12 int call_fcntl_fd_cloexec; 13 14 enum { PTY_NAME_SIZE =3D 24 }; 15 16 int emacs_open(const char *file, int oflags, int mode) { 17 #define O_CLOEXEC 0 18 int fd; 19 oflags |=3D O_CLOEXEC; 20 while ((fd =3D open(file, oflags, mode)) < 0 && errno =3D=3D = EINTR) abort(); 21 if (! O_CLOEXEC && 0 <=3D fd) { 22 fprintf(stderr, "call_fcntl_fd_cloexec: %d\n", = call_fcntl_fd_cloexec); 23 if (call_fcntl_fd_cloexec) { 24 int fcntl_result =3D fcntl(fd, F_SETFD, FD_CLOEXEC); 25 fprintf(stderr, "fcntl_result: %d\n", fcntl_result); 26 } 27 } 28 return fd; 29 } 30 31 static int allocate_pty(char pty_name[PTY_NAME_SIZE]) { 32 int fd; 33 strcpy(pty_name, "/dev/ptmx"); 34 fd =3D emacs_open(pty_name, O_RDWR | O_NONBLOCK, 0); 35 fprintf(stderr, "fd: %d\n", fd); 36 if (fd >=3D 0) { 37 int grantpt_result =3D grantpt(fd); 38 fprintf(stderr, "grantpt_result: %d\n", grantpt_result); 39 if (grantpt_result !=3D 0) { 40 fprintf(stderr, "errno: %d\n", errno); 41 perror("grantpt"); 42 } 43 } 44 return fd; 45 } 46 47 int main(int argc, char **argv) { 48 char pty_name[PTY_NAME_SIZE]; 49 if (argc =3D=3D 2) call_fcntl_fd_cloexec =3D 0; 50 else call_fcntl_fd_cloexec =3D 1; 51 allocate_pty(pty_name); 52 return 0; 53 } From unknown Mon Aug 18 22:11:46 2025 X-Loop: help-debbugs@gnu.org Subject: bug#20555: Emacs 24.2 vs 24.4 on Solaris: M-x shell and "tty => not a tty" References: <555198E2.30809@cs.ucla.edu> In-Reply-To: <555198E2.30809@cs.ucla.edu> Resent-From: =?UTF-8?Q?=E7=99=BD=E4=BA=95=E5=BD=B0?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 02 Jun 2015 16:46:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 20555 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 20555@debbugs.gnu.org Cc: Akira Shirai Received: via spool by 20555-submit@debbugs.gnu.org id=B20555.143326353422294 (code B ref 20555); Tue, 02 Jun 2015 16:46:02 +0000 Received: (at 20555) by debbugs.gnu.org; 2 Jun 2015 16:45:34 +0000 Received: from localhost ([127.0.0.1]:37827 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YzpJl-0005nV-5j for submit@debbugs.gnu.org; Tue, 02 Jun 2015 12:45:33 -0400 Received: from mail-pa0-f51.google.com ([209.85.220.51]:36495) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YzpJi-0005nH-Sf for 20555@debbugs.gnu.org; Tue, 02 Jun 2015 12:45:31 -0400 Received: by pabqy3 with SMTP id qy3so16066679pab.3 for <20555@debbugs.gnu.org>; Tue, 02 Jun 2015 09:45:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:content-type:content-transfer-encoding:subject:date:message-id :cc:to:mime-version; bh=kZgW+FycWiT4Gn1cJA9sDBY8Sq2MY1X+/WpbsIhEWCU=; b=N24dHu582fb0Sr7okHY0jcavWUF696tLvBCljsDyiMxYmUTnTwzKgjfy9R7pM0eISg BTZYSJLiV8o6ijAzFk5XYHFlyjuIuPXhScl842sVtMxJSrFfsM+DCOgS1CK7E+gNZBwM OM3epjZhlpcPsLXhMG9ss5Xz7rV5Rj+DWA+nelqM5zikmGVNm2SewVsqazLuHzU17hbb erUMEsTcDfUyKt25t96mYT54r+AAp4uOQ6r+EAwqFcnNF/rArxUruKIxxg1oY8HBSEiL HKoCuAzgthER1jZhXJ41k410Eh+9avyfBlSu/wyx8hvE8FcDo9kfPG42uG3VlOfBENbf CXJw== X-Received: by 10.66.168.105 with SMTP id zv9mr51429553pab.121.1433263524926; Tue, 02 Jun 2015 09:45:24 -0700 (PDT) Received: from [172.20.10.11] (pw126253104007.6.panda-world.ne.jp. [126.253.104.7]) by mx.google.com with ESMTPSA id pd10sm18333426pdb.66.2015.06.02.09.45.21 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 02 Jun 2015 09:45:23 -0700 (PDT) From: =?UTF-8?Q?=E7=99=BD=E4=BA=95=E5=BD=B0?= Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Date: Wed, 3 Jun 2015 01:45:21 +0900 Message-Id: Mime-Version: 1.0 (Mac OS X Mail 8.2 \(2098\)) X-Mailer: Apple Mail (2.2098) X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) Today I found the same problem on Ruby: | grantpt() doesn't work with CLOEXEC on Solaris 10 | = http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?revision=3D33519&view=3Drevisi= on They say that Solaris grantpt() internally uses a setuid root program /usr/lib/pt_chmod which receives an fd and calls ptsname(), chown(), and chmod(). If FD_CLOEXEC is set for the fd, the fd passed for /usr/lib/pt_chmod is already closed and /usr/lib/pt_chmod does not work. The following is their fix for the problem: % gzcat ruby-2.2.2.tar.gz | tar tvf - | grep ruby-2.2.2/ext/pty/pty.c -rw-r--r-- 1044/1044 22152 Nov 15 20:49 2014 ruby-2.2.2/ext/pty/pty.c % cat -n ruby-2.2.2/ext/pty/pty.c | sed -n = '221,223p;234,256p;330,341p;450p' 221 static int 222 get_device_once(int *master, int *slave, char = SlaveName[DEVICELEN], int nomesg, int fail) 223 { 234 #if defined(__sun) || (defined(__FreeBSD__) && __FreeBSD_version = < 902000) 235 /* workaround for Solaris 10: grantpt() doesn't work if = FD_CLOEXEC is set. [ruby-dev:44688] */ 236 /* FreeBSD 9.2 or later supports O_CLOEXEC 237 * http://www.freebsd.org/cgi/query-pr.cgi?pr=3D162374 */ 238 if ((masterfd =3D posix_openpt(O_RDWR|O_NOCTTY)) =3D=3D -1) = goto error; 239 if (sigaction(SIGCHLD, &dfl, &old) =3D=3D -1) goto error; 240 if (grantpt(masterfd) =3D=3D -1) goto grantpt_error; 241 rb_fd_fix_cloexec(masterfd); 242 #else 243 { 244 int flags =3D O_RDWR|O_NOCTTY; 245 # if defined(O_CLOEXEC) 246 /* glibc posix_openpt() in GNU/Linux calls = open("/dev/ptmx", flags) internally. 247 * So version dependency on GNU/Linux is same as = O_CLOEXEC with open(). 248 * O_CLOEXEC is available since Linux 2.6.23. Linux = 2.6.18 silently ignore it. */ 249 flags |=3D O_CLOEXEC; 250 # endif 251 if ((masterfd =3D posix_openpt(flags)) =3D=3D -1) goto = error; 252 } 253 rb_fd_fix_cloexec(masterfd); 254 if (sigaction(SIGCHLD, &dfl, &old) =3D=3D -1) goto error; 255 if (grantpt(masterfd) =3D=3D -1) goto grantpt_error; 256 #endif 330 #if defined(__sun) 331 /* workaround for Solaris 10: grantpt() doesn't work if = FD_CLOEXEC is set. [ruby-dev:44688] */ 332 if((masterfd =3D open("/dev/ptmx", O_RDWR, 0)) =3D=3D -1) = goto error; 333 s =3D signal(SIGCHLD, SIG_DFL); 334 if(grantpt(masterfd) =3D=3D -1) goto error; 335 rb_fd_fix_cloexec(masterfd); 336 #else 337 if((masterfd =3D rb_cloexec_open("/dev/ptmx", O_RDWR, 0)) =3D=3D= -1) goto error; 338 rb_update_max_fd(masterfd); 339 s =3D signal(SIGCHLD, SIG_DFL); 340 if(grantpt(masterfd) =3D=3D -1) goto error; 341 #endif 450 } From unknown Mon Aug 18 22:11:46 2025 X-Loop: help-debbugs@gnu.org Subject: bug#20555: Emacs 24.2 vs 24.4 on Solaris: M-x shell and "tty => not a tty" Resent-From: Glenn Morris Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 07 Jun 2015 18:12:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 20555 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Paul Eggert Cc: okshirai@gmail.com, 20555@debbugs.gnu.org Received: via spool by 20555-submit@debbugs.gnu.org id=B20555.14337007184712 (code B ref 20555); Sun, 07 Jun 2015 18:12:02 +0000 Received: (at 20555) by debbugs.gnu.org; 7 Jun 2015 18:11:58 +0000 Received: from localhost ([127.0.0.1]:44261 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Z1f37-0001Dw-Uo for submit@debbugs.gnu.org; Sun, 07 Jun 2015 14:11:58 -0400 Received: from eggs.gnu.org ([208.118.235.92]:33952) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Z1f35-0001Dg-T9 for 20555@debbugs.gnu.org; Sun, 07 Jun 2015 14:11:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z1f30-0003bb-5z for 20555@debbugs.gnu.org; Sun, 07 Jun 2015 14:11:50 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,T_RP_MATCHES_RCVD autolearn=disabled version=3.3.2 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:37763) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z1f2x-0003bD-Nm; Sun, 07 Jun 2015 14:11:47 -0400 Received: from rgm by fencepost.gnu.org with local (Exim 4.82) (envelope-from ) id 1Z1f2x-0006R6-3g; Sun, 07 Jun 2015 14:11:47 -0400 From: Glenn Morris References: <555198E2.30809@cs.ucla.edu> <9051A319-D257-400F-B74E-C46B2C14D8F3@gmail.com> X-Spook: Israel Belknap JSOFC3IP Leitrim underground Wave SRI X-Ran: 0,Ja-,R0R9>kuP[=Zowz[;mlt+z+_SbWI~3;N+1LYNW&nb/8*6,Fu(Qb/mu+66u\6c/n:i X-Hue: black X-Attribution: GM Date: Sun, 07 Jun 2015 14:11:46 -0400 In-Reply-To: <9051A319-D257-400F-B74E-C46B2C14D8F3@gmail.com> ("=?UTF-8?Q?=E7=99=BD=E4=BA=95=E5=BD=B0?="'s message of "Tue, 2 Jun 2015 01:53:12 +0900") Message-ID: User-Agent: Gnus (www.gnus.org), GNU Emacs (www.gnu.org/software/emacs/) MIME-Version: 1.0 Content-Type: text/plain X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:4830:134:3::e X-Spam-Score: -5.0 (-----) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) Paul, you are the go-to-guy for these kind of problems. Any thoughts on http://debbugs.gnu.org/20555#13 http://debbugs.gnu.org/20555#20 http://debbugs.gnu.org/20555#23 ? From unknown Mon Aug 18 22:11:46 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.503 (Entity 5.503) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Paul Eggert Subject: bug#20555: closed (Re: Emacs 24.2 vs 24.4 on Solaris: M-x shell and "tty => not a tty") Message-ID: References: <557A1E3A.3050509@cs.ucla.edu> <555198E2.30809@cs.ucla.edu> X-Gnu-PR-Message: they-closed 20555 X-Gnu-PR-Package: emacs Reply-To: 20555@debbugs.gnu.org Date: Thu, 11 Jun 2015 23:49:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1434066542-11607-1" This is a multi-part message in MIME format... ------------=_1434066542-11607-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #20555: Emacs 24.2 vs 24.4 on Solaris: M-x shell and "tty =3D> not a tty" which was filed against the emacs package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 20555@debbugs.gnu.org. --=20 20555: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D20555 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1434066542-11607-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 20555-done) by debbugs.gnu.org; 11 Jun 2015 23:48:27 +0000 Received: from localhost ([127.0.0.1]:51127 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Z3CCw-00030Q-2X for submit@debbugs.gnu.org; Thu, 11 Jun 2015 19:48:27 -0400 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:55985) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Z3CCs-00030A-DH for 20555-done@debbugs.gnu.org; Thu, 11 Jun 2015 19:48:23 -0400 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 74349160781; Thu, 11 Jun 2015 16:48:16 -0700 (PDT) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id cF0EC-9Z5r7u; Thu, 11 Jun 2015 16:48:13 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id C20C1160782; Thu, 11 Jun 2015 16:48:13 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id KTXbsjGm8o2v; Thu, 11 Jun 2015 16:48:13 -0700 (PDT) Received: from [192.168.1.9] (pool-100-32-155-148.lsanca.fios.verizon.net [100.32.155.148]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 9B15E160781; Thu, 11 Jun 2015 16:48:13 -0700 (PDT) Message-ID: <557A1E3A.3050509@cs.ucla.edu> Date: Thu, 11 Jun 2015 16:48:10 -0700 From: Paul Eggert Organization: UCLA Computer Science Department User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: Akira Shirai Subject: Re: Emacs 24.2 vs 24.4 on Solaris: M-x shell and "tty => not a tty" Content-Type: multipart/mixed; boundary="------------030105060604000901030807" X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 20555-done Cc: "Warren, John W CIV \(US\)" , 20555-done@debbugs.gnu.org, Georges Ko X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) This is a multi-part message in MIME format. --------------030105060604000901030807 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Akira Shirai, thanks for the info about grantpt and its internal setuid program; that made the problem obvious. I installed the attached patch into the Emacs master sources and am (perhaps optimistically) marking this bug as done. --------------030105060604000901030807 Content-Type: text/x-diff; name="0001-Fix-not-a-tty-bug-on-Solaris-10.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0001-Fix-not-a-tty-bug-on-Solaris-10.patch" >From 099cb9f7b8b1d00293298d947fc77b8c96120820 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Thu, 11 Jun 2015 16:41:36 -0700 Subject: [PATCH] Fix "not a tty" bug on Solaris 10 * configure.ac (PTY_OPEN): Define to plain 'open' on SVR4-derived hosts, so that the O_CLOEXEC flag isn't set. * src/process.c (allocate_pty): Set the O_CLOEXEC flag after calling PTY_TTY_NAME_SPRINTF, for the benefit of SVR4-derived hosts that call grantpt which does its work via a setuid subcommand (Bug#19191, Bug#19927, Bug#20555, Bug#20686). Also, set O_CLOEXEC even if PTY_OPEN is not defined, since it seems relevant in that case too. --- configure.ac | 5 ++++- src/process.c | 20 +++++++++++--------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/configure.ac b/configure.ac index 9c6a74a..070b061 100644 --- a/configure.ac +++ b/configure.ac @@ -4397,14 +4397,17 @@ case $opsys in ;; sol2* ) - dnl On SysVr4, grantpt(3) forks a subprocess, so keep sigchld_handler() + dnl On SysVr4, grantpt(3) forks a subprocess, so do not use + dnl O_CLOEXEC when opening the pty, and keep the SIGCHLD handler dnl from intercepting that death. If any child but grantpt's should die dnl within, it should be caught after sigrelse(2). + AC_DEFINE(PTY_OPEN, [fd = open (pty_name, O_RDWR | O_NONBLOCK)]) AC_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); }]) ;; unixware ) dnl Comments are as per sol2*. + AC_DEFINE(PTY_OPEN, [fd = open (pty_name, O_RDWR | O_NONBLOCK)]) AC_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) fatal("could not grant slave pty"); if (unlockpt(fd) == -1) fatal("could not unlock slave pty"); if (!(ptyname = ptsname(fd))) fatal ("could not enable slave pty"); snprintf (pty_name, PTY_NAME_SIZE, "%s", ptyname); }]) ;; esac diff --git a/src/process.c b/src/process.c index 17fe708..b4f979f 100644 --- a/src/process.c +++ b/src/process.c @@ -658,22 +658,24 @@ allocate_pty (char pty_name[PTY_NAME_SIZE]) if (fd >= 0) { -#ifdef PTY_OPEN +#ifdef PTY_TTY_NAME_SPRINTF + PTY_TTY_NAME_SPRINTF +#else + sprintf (pty_name, "/dev/tty%c%x", c, i); +#endif /* no PTY_TTY_NAME_SPRINTF */ + /* Set FD's close-on-exec flag. This is needed even if PT_OPEN calls posix_openpt with O_CLOEXEC, since POSIX doesn't require support for that combination. + Do this after PTY_TTY_NAME_SPRINTF, which on some platforms + doesn't work if the close-on-exec flag is set (Bug#20555). Multithreaded platforms where posix_openpt ignores O_CLOEXEC (or where PTY_OPEN doesn't call posix_openpt) have a race condition between the PTY_OPEN and here. */ fcntl (fd, F_SETFD, FD_CLOEXEC); -#endif - /* Check to make certain that both sides are available - this avoids a nasty yet stupid bug in rlogins. */ -#ifdef PTY_TTY_NAME_SPRINTF - PTY_TTY_NAME_SPRINTF -#else - sprintf (pty_name, "/dev/tty%c%x", c, i); -#endif /* no PTY_TTY_NAME_SPRINTF */ + + /* Check to make certain that both sides are available. + This avoids a nasty yet stupid bug in rlogins. */ if (faccessat (AT_FDCWD, pty_name, R_OK | W_OK, AT_EACCESS) != 0) { emacs_close (fd); -- 2.1.0 --------------030105060604000901030807-- ------------=_1434066542-11607-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 12 May 2015 06:08:58 +0000 Received: from localhost ([127.0.0.1]:41451 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Ys3NB-0000Fo-2P for submit@debbugs.gnu.org; Tue, 12 May 2015 02:08:57 -0400 Received: from eggs.gnu.org ([208.118.235.92]:33069) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Ys3N9-0000FZ-1t for submit@debbugs.gnu.org; Tue, 12 May 2015 02:08:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ys3N2-0007G1-Li for submit@debbugs.gnu.org; Tue, 12 May 2015 02:08:49 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50 autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:59399) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ys3N2-0007Fx-IO for submit@debbugs.gnu.org; Tue, 12 May 2015 02:08:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46575) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ys3N1-0002BG-Dc for bug-gnu-emacs@gnu.org; Tue, 12 May 2015 02:08:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ys3My-0007DN-2e for bug-gnu-emacs@gnu.org; Tue, 12 May 2015 02:08:47 -0400 Received: from smtp.cs.ucla.edu ([131.179.128.62]:58390) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ys3Mx-0007CK-Sw for bug-gnu-emacs@gnu.org; Tue, 12 May 2015 02:08:44 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id 06761A6000D; Mon, 11 May 2015 23:08:36 -0700 (PDT) X-Virus-Scanned: amavisd-new at smtp.cs.ucla.edu Received: from smtp.cs.ucla.edu ([127.0.0.1]) by localhost (smtp.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id mXhajxLxlkKT; Mon, 11 May 2015 23:08:35 -0700 (PDT) Received: from [192.168.1.9] (pool-100-32-155-148.lsanca.fios.verizon.net [100.32.155.148]) by smtp.cs.ucla.edu (Postfix) with ESMTPSA id EE6A1A6000C; Mon, 11 May 2015 23:08:34 -0700 (PDT) Message-ID: <555198E2.30809@cs.ucla.edu> Date: Mon, 11 May 2015 23:08:34 -0700 From: Paul Eggert Organization: UCLA Computer Science Department User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 MIME-Version: 1.0 To: Georges Ko , Emacs bug reports and feature requests Subject: Re: Emacs 24.2 vs 24.4 on Solaris: M-x shell and "tty => not a tty" References: <86twvjjj2c.fsf@gko.net> In-Reply-To: <86twvjjj2c.fsf@gko.net> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.0 (----) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.0 (----) [moving this to bug-gnu-emacs, so that it gets a proper bug number] Georges Ko wrote: > What were the changes done on Emacs 24.4 regarding subshells (or > processes), compared to version 24.2? Quite a few, I suspect. You can use 'diff' to find out the details.... > When compiled in the same environment, "tty" in a subshell > (M-x shell) has different outputs: > > - in Emacs 24.2, "tty" outputs the tty, > - in Emacs 24.4, "tty" outputs "not a tty". > > That is, if I run the command below to spawn a shell: > > (apply 'start-process "shell" "*shell*" "/bin/ksh" '("-i")) > > - in Emacs 24.2, "ps" shows the shell has a normal tty, > - in Emacs 24.4, "ps" shows the shell has a tty with "?". I don't observe either problem when running Emacs 24.5 under Solaris 11 x86-64 compiled with the bundled GCC (4.5.2). However, I do observe them when running Emacs 24.5 under Solaris 10 sparc compiled with Sun C 5.13. > I couldn't compile 24.3 due to some errors, so I don't know its behavior. Emacs 24.3 is bundled within Solaris 11.2, for what it's worth. If you're still running into problems, I suggest replying with details of how you built Emacs (version of OS and compiler, 'configure' arguments, log from 'configure' and 'make', etc.). PS. This looks a bit like Bug#9150 , but that bug was in an older Emacs, which probably means it's independent. ------------=_1434066542-11607-1-- From unknown Mon Aug 18 22:11:46 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.503 (Entity 5.503) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: =?UTF-8?Q?=E7=99=BD=E4=BA=95=E5=BD=B0?= Subject: bug#19191: closed (Re: Emacs 24.2 vs 24.4 on Solaris: M-x shell and "tty => not a tty") Message-ID: References: <557A1E3A.3050509@cs.ucla.edu> <09A01C7C-6199-4883-84AC-2445080B3FBE@gmail.com> X-Gnu-PR-Message: they-closed 19191 X-Gnu-PR-Package: emacs Reply-To: 19191@debbugs.gnu.org Date: Thu, 11 Jun 2015 23:49:03 +0000 Content-Type: multipart/mixed; boundary="----------=_1434066543-11607-3" This is a multi-part message in MIME format... ------------=_1434066543-11607-3 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #20555: 24.4; su command in *shell* buffer does not work which was filed against the emacs package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 19191@debbugs.gnu.org. --=20 20555: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D20555 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1434066543-11607-3 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 20555-done) by debbugs.gnu.org; 11 Jun 2015 23:48:27 +0000 Received: from localhost ([127.0.0.1]:51127 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Z3CCw-00030Q-2X for submit@debbugs.gnu.org; Thu, 11 Jun 2015 19:48:27 -0400 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:55985) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Z3CCs-00030A-DH for 20555-done@debbugs.gnu.org; Thu, 11 Jun 2015 19:48:23 -0400 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 74349160781; Thu, 11 Jun 2015 16:48:16 -0700 (PDT) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id cF0EC-9Z5r7u; Thu, 11 Jun 2015 16:48:13 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id C20C1160782; Thu, 11 Jun 2015 16:48:13 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id KTXbsjGm8o2v; Thu, 11 Jun 2015 16:48:13 -0700 (PDT) Received: from [192.168.1.9] (pool-100-32-155-148.lsanca.fios.verizon.net [100.32.155.148]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 9B15E160781; Thu, 11 Jun 2015 16:48:13 -0700 (PDT) Message-ID: <557A1E3A.3050509@cs.ucla.edu> Date: Thu, 11 Jun 2015 16:48:10 -0700 From: Paul Eggert Organization: UCLA Computer Science Department User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: Akira Shirai Subject: Re: Emacs 24.2 vs 24.4 on Solaris: M-x shell and "tty => not a tty" Content-Type: multipart/mixed; boundary="------------030105060604000901030807" X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 20555-done Cc: "Warren, John W CIV \(US\)" , 20555-done@debbugs.gnu.org, Georges Ko X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) This is a multi-part message in MIME format. --------------030105060604000901030807 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Akira Shirai, thanks for the info about grantpt and its internal setuid program; that made the problem obvious. I installed the attached patch into the Emacs master sources and am (perhaps optimistically) marking this bug as done. --------------030105060604000901030807 Content-Type: text/x-diff; name="0001-Fix-not-a-tty-bug-on-Solaris-10.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0001-Fix-not-a-tty-bug-on-Solaris-10.patch" >From 099cb9f7b8b1d00293298d947fc77b8c96120820 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Thu, 11 Jun 2015 16:41:36 -0700 Subject: [PATCH] Fix "not a tty" bug on Solaris 10 * configure.ac (PTY_OPEN): Define to plain 'open' on SVR4-derived hosts, so that the O_CLOEXEC flag isn't set. * src/process.c (allocate_pty): Set the O_CLOEXEC flag after calling PTY_TTY_NAME_SPRINTF, for the benefit of SVR4-derived hosts that call grantpt which does its work via a setuid subcommand (Bug#19191, Bug#19927, Bug#20555, Bug#20686). Also, set O_CLOEXEC even if PTY_OPEN is not defined, since it seems relevant in that case too. --- configure.ac | 5 ++++- src/process.c | 20 +++++++++++--------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/configure.ac b/configure.ac index 9c6a74a..070b061 100644 --- a/configure.ac +++ b/configure.ac @@ -4397,14 +4397,17 @@ case $opsys in ;; sol2* ) - dnl On SysVr4, grantpt(3) forks a subprocess, so keep sigchld_handler() + dnl On SysVr4, grantpt(3) forks a subprocess, so do not use + dnl O_CLOEXEC when opening the pty, and keep the SIGCHLD handler dnl from intercepting that death. If any child but grantpt's should die dnl within, it should be caught after sigrelse(2). + AC_DEFINE(PTY_OPEN, [fd = open (pty_name, O_RDWR | O_NONBLOCK)]) AC_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); }]) ;; unixware ) dnl Comments are as per sol2*. + AC_DEFINE(PTY_OPEN, [fd = open (pty_name, O_RDWR | O_NONBLOCK)]) AC_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) fatal("could not grant slave pty"); if (unlockpt(fd) == -1) fatal("could not unlock slave pty"); if (!(ptyname = ptsname(fd))) fatal ("could not enable slave pty"); snprintf (pty_name, PTY_NAME_SIZE, "%s", ptyname); }]) ;; esac diff --git a/src/process.c b/src/process.c index 17fe708..b4f979f 100644 --- a/src/process.c +++ b/src/process.c @@ -658,22 +658,24 @@ allocate_pty (char pty_name[PTY_NAME_SIZE]) if (fd >= 0) { -#ifdef PTY_OPEN +#ifdef PTY_TTY_NAME_SPRINTF + PTY_TTY_NAME_SPRINTF +#else + sprintf (pty_name, "/dev/tty%c%x", c, i); +#endif /* no PTY_TTY_NAME_SPRINTF */ + /* Set FD's close-on-exec flag. This is needed even if PT_OPEN calls posix_openpt with O_CLOEXEC, since POSIX doesn't require support for that combination. + Do this after PTY_TTY_NAME_SPRINTF, which on some platforms + doesn't work if the close-on-exec flag is set (Bug#20555). Multithreaded platforms where posix_openpt ignores O_CLOEXEC (or where PTY_OPEN doesn't call posix_openpt) have a race condition between the PTY_OPEN and here. */ fcntl (fd, F_SETFD, FD_CLOEXEC); -#endif - /* Check to make certain that both sides are available - this avoids a nasty yet stupid bug in rlogins. */ -#ifdef PTY_TTY_NAME_SPRINTF - PTY_TTY_NAME_SPRINTF -#else - sprintf (pty_name, "/dev/tty%c%x", c, i); -#endif /* no PTY_TTY_NAME_SPRINTF */ + + /* Check to make certain that both sides are available. + This avoids a nasty yet stupid bug in rlogins. */ if (faccessat (AT_FDCWD, pty_name, R_OK | W_OK, AT_EACCESS) != 0) { emacs_close (fd); -- 2.1.0 --------------030105060604000901030807-- ------------=_1434066543-11607-3 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 26 Nov 2014 10:01:34 +0000 Received: from localhost ([127.0.0.1]:45562 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XtZPd-0006T5-KI for submit@debbugs.gnu.org; Wed, 26 Nov 2014 05:01:34 -0500 Received: from eggs.gnu.org ([208.118.235.92]:41150) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XtZPX-0006St-Kt for submit@debbugs.gnu.org; Wed, 26 Nov 2014 05:01:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XtZPO-0005BM-9Z for submit@debbugs.gnu.org; Wed, 26 Nov 2014 05:01:23 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,FREEMAIL_FROM, T_DKIM_INVALID autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:47647) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XtZPO-0005BI-6m for submit@debbugs.gnu.org; Wed, 26 Nov 2014 05:01:14 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42807) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XtZPF-0003Bk-3y for bug-gnu-emacs@gnu.org; Wed, 26 Nov 2014 05:01:14 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XtZP5-00056s-9P for bug-gnu-emacs@gnu.org; Wed, 26 Nov 2014 05:01:05 -0500 Received: from mail-pa0-x22e.google.com ([2607:f8b0:400e:c03::22e]:33853) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XtZP5-00056X-2K for bug-gnu-emacs@gnu.org; Wed, 26 Nov 2014 05:00:55 -0500 Received: by mail-pa0-f46.google.com with SMTP id lj1so2558965pab.5 for ; Wed, 26 Nov 2014 02:00:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:content-type:content-transfer-encoding:subject:date:message-id :cc:to:mime-version; bh=tOYLDesubXUzQSG6HKv+wioDf4tWbjwveoXGMiBNh5k=; b=f0pmQj3VdYSK86p7kfZQ5I0iw1InHto6GG/soiSYEYx0+63L8hXwGLQFyrlKFfBgBx x/jw+GYMALiF/OoNE1j3AbDYiy3wr2lEokA4kTbT+sf7pY/5z0JzItT4euEAeyW5yXH/ 8q8fAL14kTwKf2OjGazx3ciWT0H7QA/+uI5Fzyi0Eo46wGizdckgkADTgRAypFFA1ar5 oMp15rin4ZHKfb8YLQ4Ih2WU4WsQa7LzPebniDEFL+idsKN9SYNtaRlJst/9X8JvYkk8 OdOZ6vKUn49y4Sm9gp190qbDIWUGvnGxJWt2SZPfNk3K6/t0Onnr5LSsyYzfLFxSbQ8F aX+w== X-Received: by 10.68.202.1 with SMTP id ke1mr51200401pbc.139.1416996053211; Wed, 26 Nov 2014 02:00:53 -0800 (PST) Received: from [172.20.10.10] (pw126255015154.9.panda-world.ne.jp. [126.255.15.154]) by mx.google.com with ESMTPSA id yp8sm3841518pab.48.2014.11.26.02.00.50 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 26 Nov 2014 02:00:52 -0800 (PST) From: =?utf-8?B?55m95LqV5b2w?= Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Subject: 24.4; su command in *shell* buffer does not work Date: Wed, 26 Nov 2014 19:00:48 +0900 Message-Id: <09A01C7C-6199-4883-84AC-2445080B3FBE@gmail.com> To: bug-gnu-emacs@gnu.org Mime-Version: 1.0 (Mac OS X Mail 8.0 \(1990.1\)) X-Mailer: Apple Mail (2.1990.1) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.0 (----) X-Debbugs-Envelope-To: submit Cc: Akira Shirai X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.0 (----) su command in *shell* buffer does not work. su does not ask for the password and exits with "su: Sorry". /* *shell* buffer (24.4) */ Warning: no access to tty; thus no job control in this shell... yokohama% su su: Sorry yokohama% su in *shell* buffer works well on emacs-24.3. /* *shell* buffer (24.3) */ yokohama% su Password:=20 # exit yokohama%=20 In GNU Emacs 24.4.1 (i386-pc-solaris2.10, X toolkit, Xaw scroll bars) of 2014-10-23 on yokohama Windowing system distributor `Sun Microsystems, Inc.', version 11.0.6410 Configured using: `configure --prefix=3D/Users/shiraiakira/i386/emacs-24.4 --with-x = --x-includes=3D/usr/dt/include:/usr/openwin/include:/Users/shiraiakira/xpm= /i386/include:/Users/shiraiakira/i386/jpeg/include:/Users/shiraiakira/i386= /zlib/include:/Users/shiraiakira/i386/libpng/include:/Users/shiraiakira/i3= 86/libungif/include:/Users/shiraiakira/i386/tiff/libtiff = --x-libraries=3D/usr/dt/lib:/usr/openwin/lib:/Users/shiraiakira/xpm/i386/l= ib:/Users/shiraiakira/i386/jpeg/lib:/Users/shiraiakira/i386/zlib/lib:/User= s/shiraiakira/i386/libpng/lib:/Users/shiraiakira/i386/libungif/lib:/Users/= shiraiakira/i386/tiff/libtiff --without-compress-install' Important settings: value of $LANG: C locale-coding-system: nil Major mode: Shell Minor modes in effect: shell-dirtrack-mode: t tooltip-mode: t electric-indent-mode: t mouse-wheel-mode: t tool-bar-mode: t menu-bar-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t blink-cursor-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t line-number-mode: t transient-mark-mode: t Recent input: M-x s h e l l s u M-x r e p o r t=20 Recent messages: For information about GNU Emacs and the GNU system, type C-h C-a. Load-path shadows: None found. Features: (shadow sort gnus-util mail-extr emacsbug message format-spec rfc822 mml easymenu mml-sec mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums mm-util help-fns mail-prsvr mail-utils shell pcomplete comint ansi-color ring time-date tooltip electric uniquify ediff-hook vc-hooks lisp-float-type mwheel x-win x-dnd tool-bar dnd fontset image regexp-opt fringe tabulated-list newcomment lisp-mode prog-mode register page menu-bar rfn-eshadow timer select scroll-bar mouse jit-lock font-lock syntax facemenu font-core frame cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean japanese hebrew greek romanian slovak czech european ethiopic indian cyrillic chinese case-table epa-hook jka-cmpr-hook help simple abbrev minibuffer nadvice loaddefs button faces cus-face macroexp files text-properties overlay sha1 md5 base64 format env code-pages mule custom widget hashtable-print-readable backquote make-network-process dynamic-setting x-toolkit x multi-tty emacs) Memory information: ((conses 8 77649 4073) (symbols 24 17821 0) (miscs 20 43 185) (strings 16 13260 3813) (string-bytes 1 362635) (vectors 8 9635) (vector-slots 4 388469 2228) (floats 8 61 197) (intervals 28 976 1434) (buffers 512 12)) ------------=_1434066543-11607-3-- From unknown Mon Aug 18 22:11:46 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.503 (Entity 5.503) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: =?UTF-8?Q?=E7=99=BD=E4=BA=95=E5=BD=B0?= Subject: bug#19927: closed (Re: Emacs 24.2 vs 24.4 on Solaris: M-x shell and "tty => not a tty") Message-ID: References: <557A1E3A.3050509@cs.ucla.edu> <09B93FBB-0E6A-4457-B368-E0CB2F98A4B8@gmail.com> X-Gnu-PR-Message: they-closed 19927 X-Gnu-PR-Package: emacs Reply-To: 19927@debbugs.gnu.org Date: Thu, 11 Jun 2015 23:49:03 +0000 Content-Type: multipart/mixed; boundary="----------=_1434066543-11607-5" This is a multi-part message in MIME format... ------------=_1434066543-11607-5 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #20555: 24.4.90; su command in *shell* buffer does not work which was filed against the emacs package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 19927@debbugs.gnu.org. --=20 20555: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D20555 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1434066543-11607-5 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 20555-done) by debbugs.gnu.org; 11 Jun 2015 23:48:27 +0000 Received: from localhost ([127.0.0.1]:51127 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Z3CCw-00030Q-2X for submit@debbugs.gnu.org; Thu, 11 Jun 2015 19:48:27 -0400 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:55985) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Z3CCs-00030A-DH for 20555-done@debbugs.gnu.org; Thu, 11 Jun 2015 19:48:23 -0400 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 74349160781; Thu, 11 Jun 2015 16:48:16 -0700 (PDT) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id cF0EC-9Z5r7u; Thu, 11 Jun 2015 16:48:13 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id C20C1160782; Thu, 11 Jun 2015 16:48:13 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id KTXbsjGm8o2v; Thu, 11 Jun 2015 16:48:13 -0700 (PDT) Received: from [192.168.1.9] (pool-100-32-155-148.lsanca.fios.verizon.net [100.32.155.148]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 9B15E160781; Thu, 11 Jun 2015 16:48:13 -0700 (PDT) Message-ID: <557A1E3A.3050509@cs.ucla.edu> Date: Thu, 11 Jun 2015 16:48:10 -0700 From: Paul Eggert Organization: UCLA Computer Science Department User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: Akira Shirai Subject: Re: Emacs 24.2 vs 24.4 on Solaris: M-x shell and "tty => not a tty" Content-Type: multipart/mixed; boundary="------------030105060604000901030807" X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 20555-done Cc: "Warren, John W CIV \(US\)" , 20555-done@debbugs.gnu.org, Georges Ko X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) This is a multi-part message in MIME format. --------------030105060604000901030807 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Akira Shirai, thanks for the info about grantpt and its internal setuid program; that made the problem obvious. I installed the attached patch into the Emacs master sources and am (perhaps optimistically) marking this bug as done. --------------030105060604000901030807 Content-Type: text/x-diff; name="0001-Fix-not-a-tty-bug-on-Solaris-10.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0001-Fix-not-a-tty-bug-on-Solaris-10.patch" >From 099cb9f7b8b1d00293298d947fc77b8c96120820 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Thu, 11 Jun 2015 16:41:36 -0700 Subject: [PATCH] Fix "not a tty" bug on Solaris 10 * configure.ac (PTY_OPEN): Define to plain 'open' on SVR4-derived hosts, so that the O_CLOEXEC flag isn't set. * src/process.c (allocate_pty): Set the O_CLOEXEC flag after calling PTY_TTY_NAME_SPRINTF, for the benefit of SVR4-derived hosts that call grantpt which does its work via a setuid subcommand (Bug#19191, Bug#19927, Bug#20555, Bug#20686). Also, set O_CLOEXEC even if PTY_OPEN is not defined, since it seems relevant in that case too. --- configure.ac | 5 ++++- src/process.c | 20 +++++++++++--------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/configure.ac b/configure.ac index 9c6a74a..070b061 100644 --- a/configure.ac +++ b/configure.ac @@ -4397,14 +4397,17 @@ case $opsys in ;; sol2* ) - dnl On SysVr4, grantpt(3) forks a subprocess, so keep sigchld_handler() + dnl On SysVr4, grantpt(3) forks a subprocess, so do not use + dnl O_CLOEXEC when opening the pty, and keep the SIGCHLD handler dnl from intercepting that death. If any child but grantpt's should die dnl within, it should be caught after sigrelse(2). + AC_DEFINE(PTY_OPEN, [fd = open (pty_name, O_RDWR | O_NONBLOCK)]) AC_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); }]) ;; unixware ) dnl Comments are as per sol2*. + AC_DEFINE(PTY_OPEN, [fd = open (pty_name, O_RDWR | O_NONBLOCK)]) AC_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) fatal("could not grant slave pty"); if (unlockpt(fd) == -1) fatal("could not unlock slave pty"); if (!(ptyname = ptsname(fd))) fatal ("could not enable slave pty"); snprintf (pty_name, PTY_NAME_SIZE, "%s", ptyname); }]) ;; esac diff --git a/src/process.c b/src/process.c index 17fe708..b4f979f 100644 --- a/src/process.c +++ b/src/process.c @@ -658,22 +658,24 @@ allocate_pty (char pty_name[PTY_NAME_SIZE]) if (fd >= 0) { -#ifdef PTY_OPEN +#ifdef PTY_TTY_NAME_SPRINTF + PTY_TTY_NAME_SPRINTF +#else + sprintf (pty_name, "/dev/tty%c%x", c, i); +#endif /* no PTY_TTY_NAME_SPRINTF */ + /* Set FD's close-on-exec flag. This is needed even if PT_OPEN calls posix_openpt with O_CLOEXEC, since POSIX doesn't require support for that combination. + Do this after PTY_TTY_NAME_SPRINTF, which on some platforms + doesn't work if the close-on-exec flag is set (Bug#20555). Multithreaded platforms where posix_openpt ignores O_CLOEXEC (or where PTY_OPEN doesn't call posix_openpt) have a race condition between the PTY_OPEN and here. */ fcntl (fd, F_SETFD, FD_CLOEXEC); -#endif - /* Check to make certain that both sides are available - this avoids a nasty yet stupid bug in rlogins. */ -#ifdef PTY_TTY_NAME_SPRINTF - PTY_TTY_NAME_SPRINTF -#else - sprintf (pty_name, "/dev/tty%c%x", c, i); -#endif /* no PTY_TTY_NAME_SPRINTF */ + + /* Check to make certain that both sides are available. + This avoids a nasty yet stupid bug in rlogins. */ if (faccessat (AT_FDCWD, pty_name, R_OK | W_OK, AT_EACCESS) != 0) { emacs_close (fd); -- 2.1.0 --------------030105060604000901030807-- ------------=_1434066543-11607-5 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 23 Feb 2015 16:41:15 +0000 Received: from localhost ([127.0.0.1]:51587 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YPw4I-00046u-H5 for submit@debbugs.gnu.org; Mon, 23 Feb 2015 11:41:15 -0500 Received: from eggs.gnu.org ([208.118.235.92]:52861) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YPw4F-00046m-Tr for submit@debbugs.gnu.org; Mon, 23 Feb 2015 11:41:12 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YPw4E-0004aO-MY for submit@debbugs.gnu.org; Mon, 23 Feb 2015 11:41:11 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,FREEMAIL_FROM, T_DKIM_INVALID autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:55414) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YPw4E-0004aK-JO for submit@debbugs.gnu.org; Mon, 23 Feb 2015 11:41:10 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54581) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YPw4D-0006Ib-HP for bug-gnu-emacs@gnu.org; Mon, 23 Feb 2015 11:41:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YPw48-0004Zf-9k for bug-gnu-emacs@gnu.org; Mon, 23 Feb 2015 11:41:09 -0500 Received: from mail-pd0-x22f.google.com ([2607:f8b0:400e:c02::22f]:42562) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YPw48-0004ZT-2R for bug-gnu-emacs@gnu.org; Mon, 23 Feb 2015 11:41:04 -0500 Received: by pdbfp1 with SMTP id fp1so26545908pdb.9 for ; Mon, 23 Feb 2015 08:41:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:content-type:content-transfer-encoding:subject:date:message-id :cc:to:mime-version; bh=aJavS/xOaTM0yYNzrJNXlAFNp5YmvuRrOxyOMoj/HI0=; b=F5KIIISjYRW1+IWt9MQdmb9gXc18dEZskr139Un9da+2BPcJOcBD69DppAQQ+AkcD4 lqJ8oQTJDDJjPH5zWmzzLvWerkeJ4eXJOjYaTq1a7Hd1rflPv+H+McCwbXMoUIbzQzdK wsb/vBihwlllwa8xQY1apsmuMRkuvSngIK7YHz1U8VdVWONfaxoudwTnKBaAqP2dE5H2 tN84DVvd3yBjrd13D4YmGGSpR6Vbzrss8ax4IJqs1yVpzS6X13aaB/H0TGDjSH3HNwud KGSVerPHrXIivMBNeHd3G6hrfNvnI4HqayzqFPI8bkSl6nGezmqfhLfk1GX6+UFjCqZK Mq/A== X-Received: by 10.68.69.40 with SMTP id b8mr20699477pbu.88.1424709662808; Mon, 23 Feb 2015 08:41:02 -0800 (PST) Received: from [172.20.10.11] (pw126254000127.8.panda-world.ne.jp. [126.254.0.127]) by mx.google.com with ESMTPSA id ia9sm13044086pbc.26.2015.02.23.08.41.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 23 Feb 2015 08:41:01 -0800 (PST) From: =?utf-8?B?55m95LqV5b2w?= Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Subject: 24.4.90; su command in *shell* buffer does not work Date: Tue, 24 Feb 2015 01:40:57 +0900 Message-Id: <09B93FBB-0E6A-4457-B368-E0CB2F98A4B8@gmail.com> To: bug-gnu-emacs@gnu.org Mime-Version: 1.0 (Mac OS X Mail 8.2 \(2070.6\)) X-Mailer: Apple Mail (2.2070.6) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.0 (----) X-Debbugs-Envelope-To: submit Cc: Akira Shirai X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.0 (----) su command in *shell* buffer does not work. su does not ask for the password and exits with "su: Sorry". The value of process-connection-type variable is t. There are no .zshenv, .zprofile, .zshrc, .zlogin, .zlogout, .cshrc and = .login. 1. emacs -Q 2. M-x shell /* *shell* buffer (24.4.90) */ Warning: no access to tty; thus no job control in this shell... yokohama% su su: Sorry yokohama% In GNU Emacs 24.4.90.1 (i386-pc-solaris2.10, X toolkit, Xaw scroll bars) of 2015-02-23 on yokohama Windowing system distributor `Colin Harrison', version 11.0.60900031 Configured using: `configure --prefix=3D/Users/shiraiakira/emacs-24.4.90 --with-x = --x-includes=3D/usr/dt/include:/usr/openwin/include:/Users/shiraiakira/xpm= /include:/Users/shiraiakira/jpeg/include:/Users/shiraiakira/zlib/include:/= Users/shiraiakira/libpng/include:/Users/shiraiakira/libungif/include:/User= s/shiraiakira/tiff/include = --x-libraries=3D/usr/dt/lib:/usr/openwin/lib:/Users/shiraiakira/xpm/lib:/U= sers/shiraiakira/jpeg/lib:/Users/shiraiakira/zlib/lib:/Users/shiraiakira/l= ibpng/lib:/Users/shiraiakira/libungif/lib:/Users/shiraiakira/tiff/lib --with-tiff=3Dno --with-jpeg=3Dno --without-compress-install' Important settings: value of $LANG: C locale-coding-system: nil Major mode: Shell Minor modes in effect: shell-dirtrack-mode: t tooltip-mode: t electric-indent-mode: t mouse-wheel-mode: t tool-bar-mode: t menu-bar-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t blink-cursor-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t line-number-mode: t transient-mark-mode: t Recent messages: For information about GNU Emacs and the GNU system, type C-h C-a. Load-path shadows: None found. Features: (shadow sort gnus-util mail-extr emacsbug message format-spec rfc822 mml easymenu mml-sec mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums mm-util help-fns mail-prsvr mail-utils shell pcomplete comint ansi-color ring time-date tooltip electric uniquify ediff-hook vc-hooks lisp-float-type mwheel x-win x-dnd tool-bar dnd fontset image regexp-opt fringe tabulated-list newcomment lisp-mode prog-mode register page menu-bar rfn-eshadow timer select scroll-bar mouse jit-lock font-lock syntax facemenu font-core frame cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean japanese hebrew greek romanian slovak czech european ethiopic indian cyrillic chinese case-table epa-hook jka-cmpr-hook help simple abbrev minibuffer nadvice loaddefs button faces cus-face macroexp files text-properties overlay sha1 md5 base64 format env code-pages mule custom widget hashtable-print-readable backquote make-network-process dynamic-setting x-toolkit x multi-tty emacs) Memory information: ((conses 8 77824 7776) (symbols 24 17811 0) (miscs 20 47 178) (strings 16 12096 3717) (string-bytes 1 330512) (vectors 8 9639) (vector-slots 4 388894 5895) (floats 8 61 263) (intervals 28 986 1632) (buffers 512 12)) ------------=_1434066543-11607-5-- From unknown Mon Aug 18 22:11:46 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.503 (Entity 5.503) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: "Warren, John W CIV (US)" Subject: bug#20686: closed (Re: Emacs 24.2 vs 24.4 on Solaris: M-x shell and "tty => not a tty") Message-ID: References: <557A1E3A.3050509@cs.ucla.edu> <505702541799464FA9B1EA4D58289A447FDA1445@umechpao6.easf.csd.disa.mil> X-Gnu-PR-Message: they-closed 20686 X-Gnu-PR-Package: emacs Reply-To: 20686@debbugs.gnu.org Date: Thu, 11 Jun 2015 23:49:04 +0000 Content-Type: multipart/mixed; boundary="----------=_1434066544-11607-7" This is a multi-part message in MIME format... ------------=_1434066544-11607-7 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #20555: "No access to tty" in Emacs shell which was filed against the emacs package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 20686@debbugs.gnu.org. --=20 20555: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D20555 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1434066544-11607-7 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 20555-done) by debbugs.gnu.org; 11 Jun 2015 23:48:27 +0000 Received: from localhost ([127.0.0.1]:51127 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Z3CCw-00030Q-2X for submit@debbugs.gnu.org; Thu, 11 Jun 2015 19:48:27 -0400 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:55985) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Z3CCs-00030A-DH for 20555-done@debbugs.gnu.org; Thu, 11 Jun 2015 19:48:23 -0400 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 74349160781; Thu, 11 Jun 2015 16:48:16 -0700 (PDT) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id cF0EC-9Z5r7u; Thu, 11 Jun 2015 16:48:13 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id C20C1160782; Thu, 11 Jun 2015 16:48:13 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id KTXbsjGm8o2v; Thu, 11 Jun 2015 16:48:13 -0700 (PDT) Received: from [192.168.1.9] (pool-100-32-155-148.lsanca.fios.verizon.net [100.32.155.148]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 9B15E160781; Thu, 11 Jun 2015 16:48:13 -0700 (PDT) Message-ID: <557A1E3A.3050509@cs.ucla.edu> Date: Thu, 11 Jun 2015 16:48:10 -0700 From: Paul Eggert Organization: UCLA Computer Science Department User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: Akira Shirai Subject: Re: Emacs 24.2 vs 24.4 on Solaris: M-x shell and "tty => not a tty" Content-Type: multipart/mixed; boundary="------------030105060604000901030807" X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 20555-done Cc: "Warren, John W CIV \(US\)" , 20555-done@debbugs.gnu.org, Georges Ko X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) This is a multi-part message in MIME format. --------------030105060604000901030807 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Akira Shirai, thanks for the info about grantpt and its internal setuid program; that made the problem obvious. I installed the attached patch into the Emacs master sources and am (perhaps optimistically) marking this bug as done. --------------030105060604000901030807 Content-Type: text/x-diff; name="0001-Fix-not-a-tty-bug-on-Solaris-10.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0001-Fix-not-a-tty-bug-on-Solaris-10.patch" >From 099cb9f7b8b1d00293298d947fc77b8c96120820 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Thu, 11 Jun 2015 16:41:36 -0700 Subject: [PATCH] Fix "not a tty" bug on Solaris 10 * configure.ac (PTY_OPEN): Define to plain 'open' on SVR4-derived hosts, so that the O_CLOEXEC flag isn't set. * src/process.c (allocate_pty): Set the O_CLOEXEC flag after calling PTY_TTY_NAME_SPRINTF, for the benefit of SVR4-derived hosts that call grantpt which does its work via a setuid subcommand (Bug#19191, Bug#19927, Bug#20555, Bug#20686). Also, set O_CLOEXEC even if PTY_OPEN is not defined, since it seems relevant in that case too. --- configure.ac | 5 ++++- src/process.c | 20 +++++++++++--------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/configure.ac b/configure.ac index 9c6a74a..070b061 100644 --- a/configure.ac +++ b/configure.ac @@ -4397,14 +4397,17 @@ case $opsys in ;; sol2* ) - dnl On SysVr4, grantpt(3) forks a subprocess, so keep sigchld_handler() + dnl On SysVr4, grantpt(3) forks a subprocess, so do not use + dnl O_CLOEXEC when opening the pty, and keep the SIGCHLD handler dnl from intercepting that death. If any child but grantpt's should die dnl within, it should be caught after sigrelse(2). + AC_DEFINE(PTY_OPEN, [fd = open (pty_name, O_RDWR | O_NONBLOCK)]) AC_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); }]) ;; unixware ) dnl Comments are as per sol2*. + AC_DEFINE(PTY_OPEN, [fd = open (pty_name, O_RDWR | O_NONBLOCK)]) AC_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) fatal("could not grant slave pty"); if (unlockpt(fd) == -1) fatal("could not unlock slave pty"); if (!(ptyname = ptsname(fd))) fatal ("could not enable slave pty"); snprintf (pty_name, PTY_NAME_SIZE, "%s", ptyname); }]) ;; esac diff --git a/src/process.c b/src/process.c index 17fe708..b4f979f 100644 --- a/src/process.c +++ b/src/process.c @@ -658,22 +658,24 @@ allocate_pty (char pty_name[PTY_NAME_SIZE]) if (fd >= 0) { -#ifdef PTY_OPEN +#ifdef PTY_TTY_NAME_SPRINTF + PTY_TTY_NAME_SPRINTF +#else + sprintf (pty_name, "/dev/tty%c%x", c, i); +#endif /* no PTY_TTY_NAME_SPRINTF */ + /* Set FD's close-on-exec flag. This is needed even if PT_OPEN calls posix_openpt with O_CLOEXEC, since POSIX doesn't require support for that combination. + Do this after PTY_TTY_NAME_SPRINTF, which on some platforms + doesn't work if the close-on-exec flag is set (Bug#20555). Multithreaded platforms where posix_openpt ignores O_CLOEXEC (or where PTY_OPEN doesn't call posix_openpt) have a race condition between the PTY_OPEN and here. */ fcntl (fd, F_SETFD, FD_CLOEXEC); -#endif - /* Check to make certain that both sides are available - this avoids a nasty yet stupid bug in rlogins. */ -#ifdef PTY_TTY_NAME_SPRINTF - PTY_TTY_NAME_SPRINTF -#else - sprintf (pty_name, "/dev/tty%c%x", c, i); -#endif /* no PTY_TTY_NAME_SPRINTF */ + + /* Check to make certain that both sides are available. + This avoids a nasty yet stupid bug in rlogins. */ if (faccessat (AT_FDCWD, pty_name, R_OK | W_OK, AT_EACCESS) != 0) { emacs_close (fd); -- 2.1.0 --------------030105060604000901030807-- ------------=_1434066544-11607-7 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 28 May 2015 20:06:24 +0000 Received: from localhost ([127.0.0.1]:59817 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Yy44N-0006Pz-LV for submit@debbugs.gnu.org; Thu, 28 May 2015 16:06:24 -0400 Received: from eggs.gnu.org ([208.118.235.92]:39703) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Yy3gy-0005oR-5R for submit@debbugs.gnu.org; Thu, 28 May 2015 15:42:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Yy3gr-0008BI-CQ for submit@debbugs.gnu.org; Thu, 28 May 2015 15:42:06 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50 autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:36624) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yy3gr-0008B8-9F for submit@debbugs.gnu.org; Thu, 28 May 2015 15:42:05 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53199) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yy3gp-00088g-Sx for bug-gnu-emacs@gnu.org; Thu, 28 May 2015 15:42:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Yy3gl-000893-SP for bug-gnu-emacs@gnu.org; Thu, 28 May 2015 15:42:03 -0400 Received: from uhil19pa15.eemsg.mail.mil ([214.24.21.88]:32598) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yy3gl-000872-Ms for bug-gnu-emacs@gnu.org; Thu, 28 May 2015 15:41:59 -0400 Received: from edge-mech02.mail.mil ([214.21.130.231]) by uhil19pa15.eemsg.mail.mil with ESMTP; 28 May 2015 19:41:56 +0000 Received: from UMECHPAOV.easf.csd.disa.mil (214.21.130.165) by edge-mech02.mail.mil (214.21.130.231) with Microsoft SMTP Server (TLS) id 14.3.224.2; Thu, 28 May 2015 19:41:51 +0000 Received: from UMECHPAO6.easf.csd.disa.mil ([169.254.1.97]) by umechpaov.easf.csd.disa.mil ([214.21.130.165]) with mapi id 14.03.0224.002; Thu, 28 May 2015 19:41:51 +0000 From: "Warren, John W CIV (US)" To: "bug-gnu-emacs@gnu.org" Subject: "No access to tty" in Emacs shell Thread-Topic: "No access to tty" in Emacs shell Thread-Index: AdCZfiOZEzHWGpGmTS6uMlW+Wtiefw== Date: Thu, 28 May 2015 19:41:50 +0000 Message-ID: <505702541799464FA9B1EA4D58289A447FDA1445@umechpao6.easf.csd.disa.mil> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [214.21.44.13] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Thu, 28 May 2015 16:06:21 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) Error message in *shell* buffer on entering shell mode: "Warning: no access to tty; thus no job control in this shell..." Note: The affected system does not have an internet connection, but I can sneaker-net files across. John Warren Output of report-emacs-bug follows: ---------------------------------------- From: john@lanai.i-did-not-set--mail-host-address--so-tickle-me To: bug-gnu-emacs@gnu.org Subject: 24.4; No access to tty in Emacs shell --text follows this line-- In GNU Emacs 24.4.1 (sparc-sun-solaris2.10, X toolkit, Xaw scroll bars) of 2015-05-27 on lanai Windowing system distributor `Sun Microsystems, Inc.', version 11.0.6620 Configured using: `configure --with-gif=3Dno --prefix=3D/home/john/local' Important settings: value of $LANG: C locale-coding-system: nil Major mode: Shell Minor modes in effect: shell-dirtrack-mode: t tooltip-mode: t electric-indent-mode: t mouse-wheel-mode: t tool-bar-mode: t menu-bar-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t blink-cursor-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t line-number-mode: t transient-mark-mode: t Recent input: x s h e l l x r e p o r t - e m a c s - b u g Recent messages: For information about GNU Emacs and the GNU system, type C-h C-a. Load-path shadows: None found. Features: (shadow sort gnus-util mail-extr emacsbug message format-spec rfc822 mml easymenu mml-sec mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums mm-util help-fns mail-prsvr mail-utils shell pcomplete comint ansi-color ring time-date tooltip electric uniquify ediff-hook vc-hooks lisp-float-type mwheel x-win x-dnd tool-bar dnd fontset image regexp-opt fringe tabulated-list newcomment lisp-mode prog-mode register page menu-bar rfn-eshadow timer select scroll-bar mouse jit-lock font-lock syntax facemenu font-core frame cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean japanese hebrew greek romanian slovak czech european ethiopic indian cyrillic chinese case-table epa-hook jka-cmpr-hook help simple abbrev minibuffer nadvice loaddefs button faces cus-face macroexp files text-properties overlay sha1 md5 base64 format env code-pages mule custom widget hashtable-print-readable backquote make-network-process dynamic-setting font-render-setting x-toolkit x multi-tty emacs) Memory information: ((conses 8 76071 5644) (symbols 24 17840 0) (miscs 20 47 126) (strings 16 11244 3372) (string-bytes 1 310941) (vectors 8 10332) (vector-slots 4 399617 2538) (floats 8 65 200) (intervals 28 220 236) (buffers 512 12)) -------------------------------- ------------=_1434066544-11607-7--