From debbugs-submit-bounces@debbugs.gnu.org Tue May 12 02:08:57 2015 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. From debbugs-submit-bounces@debbugs.gnu.org Tue May 12 02:36:08 2015 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 To: Paul Eggert Subject: Re: bug#20555: Emacs 24.2 vs 24.4 on Solaris: M-x shell and "tty => not a tty" 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-Debbugs-No-Ack: yes 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-Debbugs-Envelope-To: 20555 Cc: 20555@debbugs.gnu.org, gko@gko.net 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 debbugs-submit-bounces@debbugs.gnu.org Wed May 13 11:22:40 2015 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/ To: bug-gnu-emacs@gnu.org From: Georges Ko Subject: Re: bug#20555: Emacs 24.2 vs 24.4 on Solaris: M-x shell and "tty => not a tty" 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-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Wed, 13 May 2015 11:22:35 -0400 Cc: okshirai@gmail.com 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 debbugs-submit-bounces@debbugs.gnu.org Mon Jun 01 12:53:26 2015 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?B?55m95LqV5b2w?= Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Subject: Re: bug#20555: Emacs 24.2 vs 24.4 on Solaris: M-x shell and "tty => not a tty" Date: Tue, 2 Jun 2015 01:53:12 +0900 Message-Id: <9051A319-D257-400F-B74E-C46B2C14D8F3@gmail.com> To: 20555@debbugs.gnu.org Mime-Version: 1.0 (Mac OS X Mail 8.2 \(2098\)) X-Mailer: Apple Mail (2.2098) X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 20555 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: -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 debbugs-submit-bounces@debbugs.gnu.org Tue Jun 02 12:45:34 2015 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?B?55m95LqV5b2w?= Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Subject: Re: bug#20555: Emacs 24.2 vs 24.4 on Solaris: M-x shell and "tty => not a tty" Date: Wed, 3 Jun 2015 01:45:21 +0900 Message-Id: To: 20555@debbugs.gnu.org Mime-Version: 1.0 (Mac OS X Mail 8.2 \(2098\)) X-Mailer: Apple Mail (2.2098) X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 20555 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: -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 debbugs-submit-bounces@debbugs.gnu.org Sun Jun 07 14:11:58 2015 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 To: Paul Eggert Subject: Re: bug#20555: Emacs 24.2 vs 24.4 on Solaris: M-x shell and "tty => not a tty" 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?B?IueZveS6leW9sCIncw==?= 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-Debbugs-Envelope-To: 20555 Cc: okshirai@gmail.com, 20555@debbugs.gnu.org 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 debbugs-submit-bounces@debbugs.gnu.org Thu Jun 11 19:48:27 2015 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-- From unknown Mon Aug 18 04:47:04 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Fri, 10 Jul 2015 11:24:04 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator