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);