From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: "Jan D." Newsgroups: gmane.emacs.devel Subject: Re: [angeloff@acm.org: Emacs bug with Solaris 9 (only)] Date: Sat, 15 Feb 2003 22:59:45 +0100 (CET) Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: <200302152253.h1FMrw3B013807@stubby.bodenonline.com> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary=ELM741346034-190-0_ Content-Transfer-Encoding: 8bit X-Trace: main.gmane.org 1045346432 25291 80.91.224.249 (15 Feb 2003 22:00:32 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Sat, 15 Feb 2003 22:00:32 +0000 (UTC) Cc: angeloff@acm.org Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 18kAMF-0006Zg-00 for ; Sat, 15 Feb 2003 23:00:27 +0100 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.12 #1 (Debian)) id 18kAZr-00033F-00 for ; Sat, 15 Feb 2003 23:14:31 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 18kAO3-0002D9-03 for emacs-devel@quimby.gnus.org; Sat, 15 Feb 2003 17:02:19 -0500 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.10.13) id 18kAMm-0001K1-00 for emacs-devel@gnu.org; Sat, 15 Feb 2003 17:01:00 -0500 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10.13) id 18kAMI-0000se-00 for emacs-devel@gnu.org; Sat, 15 Feb 2003 17:00:35 -0500 Original-Received: from stubby.bodenonline.com ([193.201.16.94]) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 18kAM5-0000kw-00; Sat, 15 Feb 2003 17:00:17 -0500 Original-Received: from accessno42.bodenonline.com (IDENT:root@accessno42.bodenonline.com [193.201.16.44]) h1FMrw3B013807; Sat, 15 Feb 2003 23:53:58 +0100 In-Reply-To: "from (env: jhd) at Feb 15, 2003 01:52:30 pm" Original-To: emacs-devel@gnu.org Original-cc: rms@gnu.org X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1b5 Precedence: list List-Id: Emacs development discussions. List-Help: List-Post: List-Subscribe: , List-Archive: List-Unsubscribe: , Errors-To: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:11679 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:11679 --ELM741346034-190-0_ Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII Hello. Attached are the patches I think should go in, provided my observation that p->subtty is always Qnil is correct. Jan D. --ELM741346034-190-0_ Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=ISO-8859-1 Content-Disposition: attachment; filename=emacsRC.diff Index: src/process.c =================================================================== RCS file: /cvsroot/emacs/emacs/src/process.c,v retrieving revision 1.341.4.3 diff -c -r1.341.4.3 process.c *** src/process.c 23 Oct 2002 17:40:15 -0000 1.341.4.3 --- src/process.c 15 Feb 2003 16:56:35 -0000 *************** *** 3571,3576 **** --- 3571,3603 ---- return Qnil; } + /* Return the foreground process group for the tty/pty that + the process P uses. */ + static int + emacs_get_tty_pgrp (p) + struct Lisp_Process *p; + { + int gid = -1; + + #ifdef TIOCGPGRP + if (ioctl (XINT (p->infd), TIOCGPGRP, &gid) == -1 && ! NILP (p->tty_name)) + { + int fd; + /* Some OS:es (Solaris 8/9) does not allow TIOCGPGRP from the + master side. Try the slave side. */ + fd = emacs_open (XSTRING (p->tty_name)->data, O_RDONLY, 0); + + if (fd != -1) + { + ioctl (fd, TIOCGPGRP, &gid); + emacs_close (fd); + } + } + #endif /* defined (TIOCGPGRP ) */ + + return gid; + } + DEFUN ("process-running-child-p", Fprocess_running_child_p, Sprocess_running_child_p, 0, 1, 0, "Return t if PROCESS has given the terminal to a child.\n\ *************** *** 3581,3587 **** { /* Initialize in case ioctl doesn't exist or gives an error, in a way that will cause returning t. */ ! int gid = 0; Lisp_Object proc; struct Lisp_Process *p; --- 3608,3614 ---- { /* Initialize in case ioctl doesn't exist or gives an error, in a way that will cause returning t. */ ! int gid; Lisp_Object proc; struct Lisp_Process *p; *************** *** 3595,3606 **** error ("Process %s is not active", XSTRING (p->name)->data); ! #ifdef TIOCGPGRP ! if (!NILP (p->subtty)) ! ioctl (XFASTINT (p->subtty), TIOCGPGRP, &gid); ! else ! ioctl (XINT (p->infd), TIOCGPGRP, &gid); ! #endif /* defined (TIOCGPGRP ) */ if (gid == XFASTINT (p->pid)) return Qnil; --- 3622,3628 ---- error ("Process %s is not active", XSTRING (p->name)->data); ! gid = emacs_get_tty_pgrp (p); if (gid == XFASTINT (p->pid)) return Qnil; *************** *** 3747,3765 **** But, TIOCGPGRP does not work on E50 ;-P works fine on E60" His patch indicates that if TIOCGPGRP returns an error, then we should just assume that p->pid is also the process group id. */ - { - int err; ! if (!NILP (p->subtty)) ! err = ioctl (XFASTINT (p->subtty), TIOCGPGRP, &gid); ! else ! err = ioctl (XINT (p->infd), TIOCGPGRP, &gid); #ifdef pfa ! if (err == -1) ! gid = - XFASTINT (p->pid); #endif /* ! defined (pfa) */ ! } if (gid == -1) no_pgrp = 1; else --- 3769,3782 ---- But, TIOCGPGRP does not work on E50 ;-P works fine on E60" His patch indicates that if TIOCGPGRP returns an error, then we should just assume that p->pid is also the process group id. */ ! gid = emacs_get_tty_pgrp (p); #ifdef pfa ! if (gid == -1) ! gid = - XFASTINT (p->pid); #endif /* ! defined (pfa) */ ! if (gid == -1) no_pgrp = 1; else *************** *** 3821,3827 **** /* gid may be a pid, or minus a pgrp's number */ #ifdef TIOCSIGSEND if (!NILP (current_group)) ! ioctl (XINT (p->infd), TIOCSIGSEND, signo); else { gid = - XFASTINT (p->pid); --- 3838,3847 ---- /* gid may be a pid, or minus a pgrp's number */ #ifdef TIOCSIGSEND if (!NILP (current_group)) ! { ! if (ioctl (XINT (p->infd), TIOCSIGSEND, signo) == -1) ! EMACS_KILLPG (-gid, signo); ! } else { gid = - XFASTINT (p->pid); --ELM741346034-190-0_ Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=ISO-8859-1 Content-Disposition: attachment; filename=emacsCVS.diff Index: src/process.c =================================================================== RCS file: /cvsroot/emacs/emacs/src/process.c,v retrieving revision 1.399 diff -c -r1.399 process.c *** src/process.c 10 Feb 2003 13:51:43 -0000 1.399 --- src/process.c 15 Feb 2003 16:57:10 -0000 *************** *** 5104,5109 **** --- 5104,5136 ---- return Qnil; } + /* Return the foreground process group for the tty/pty that + the process P uses. */ + static int + emacs_get_tty_pgrp (p) + struct Lisp_Process *p; + { + int gid = -1; + + #ifdef TIOCGPGRP + if (ioctl (XINT (p->infd), TIOCGPGRP, &gid) == -1 && ! NILP (p->tty_name)) + { + int fd; + /* Some OS:es (Solaris 8/9) does not allow TIOCGPGRP from the + master side. Try the slave side. */ + fd = emacs_open (XSTRING (p->tty_name)->data, O_RDONLY, 0); + + if (fd != -1) + { + ioctl (fd, TIOCGPGRP, &gid); + emacs_close (fd); + } + } + #endif /* defined (TIOCGPGRP ) */ + + return gid; + } + DEFUN ("process-running-child-p", Fprocess_running_child_p, Sprocess_running_child_p, 0, 1, 0, doc: /* Return t if PROCESS has given the terminal to a child. *************** *** 5114,5120 **** { /* Initialize in case ioctl doesn't exist or gives an error, in a way that will cause returning t. */ ! int gid = 0; Lisp_Object proc; struct Lisp_Process *p; --- 5141,5147 ---- { /* Initialize in case ioctl doesn't exist or gives an error, in a way that will cause returning t. */ ! int gid; Lisp_Object proc; struct Lisp_Process *p; *************** *** 5128,5139 **** error ("Process %s is not active", SDATA (p->name)); ! #ifdef TIOCGPGRP ! if (!NILP (p->subtty)) ! ioctl (XFASTINT (p->subtty), TIOCGPGRP, &gid); ! else ! ioctl (XINT (p->infd), TIOCGPGRP, &gid); ! #endif /* defined (TIOCGPGRP ) */ if (gid == XFASTINT (p->pid)) return Qnil; --- 5155,5161 ---- error ("Process %s is not active", SDATA (p->name)); ! gid = emacs_get_tty_pgrp (p); if (gid == XFASTINT (p->pid)) return Qnil; *************** *** 5285,5303 **** But, TIOCGPGRP does not work on E50 ;-P works fine on E60" His patch indicates that if TIOCGPGRP returns an error, then we should just assume that p->pid is also the process group id. */ - { - int err; ! if (!NILP (p->subtty)) ! err = ioctl (XFASTINT (p->subtty), TIOCGPGRP, &gid); ! else ! err = ioctl (XINT (p->infd), TIOCGPGRP, &gid); ! ! if (err == -1) ! /* If we can't get the information, assume ! the shell owns the tty. */ ! gid = XFASTINT (p->pid); ! } /* It is not clear whether anything really can set GID to -1. Perhaps on some system one of those ioctls can or could do so. --- 5307,5319 ---- But, TIOCGPGRP does not work on E50 ;-P works fine on E60" His patch indicates that if TIOCGPGRP returns an error, then we should just assume that p->pid is also the process group id. */ ! gid = emacs_get_tty_pgrp (p); ! ! if (gid == -1) ! /* If we can't get the information, assume ! the shell owns the tty. */ ! gid = XFASTINT (p->pid); /* It is not clear whether anything really can set GID to -1. Perhaps on some system one of those ioctls can or could do so. *************** *** 5359,5365 **** /* gid may be a pid, or minus a pgrp's number */ #ifdef TIOCSIGSEND if (!NILP (current_group)) ! ioctl (XINT (p->infd), TIOCSIGSEND, signo); else { gid = - XFASTINT (p->pid); --- 5375,5384 ---- /* gid may be a pid, or minus a pgrp's number */ #ifdef TIOCSIGSEND if (!NILP (current_group)) ! { ! if (ioctl (XINT (p->infd), TIOCSIGSEND, signo) == -1) ! EMACS_KILLPG (gid, signo); ! } else { gid = - XFASTINT (p->pid); --ELM741346034-190-0_ Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit _______________________________________________ Emacs-devel mailing list Emacs-devel@gnu.org http://mail.gnu.org/mailman/listinfo/emacs-devel --ELM741346034-190-0_--