emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] Changes to emacs/src/process.c


From: Jan Djärv
Subject: [Emacs-diffs] Changes to emacs/src/process.c
Date: Sun, 23 Feb 2003 13:57:54 -0500

Index: emacs/src/process.c
diff -c emacs/src/process.c:1.401 emacs/src/process.c:1.402
*** emacs/src/process.c:1.401   Fri Feb 21 03:05:55 2003
--- emacs/src/process.c Fri Feb 21 13:13:53 2003
***************
*** 1782,1792 ****
    chan_process[inchannel] = process;
    XSETINT (XPROCESS (process)->infd, inchannel);
    XSETINT (XPROCESS (process)->outfd, outchannel);
!   /* Record the tty descriptor used in the subprocess.  */
!   if (forkin < 0)
!     XPROCESS (process)->subtty = Qnil;
!   else
!     XSETFASTINT (XPROCESS (process)->subtty, forkin);
    XPROCESS (process)->pty_flag = (pty_flag ? Qt : Qnil);
    XPROCESS (process)->status = Qrun;
    setup_process_coding_systems (process);
--- 1782,1793 ----
    chan_process[inchannel] = process;
    XSETINT (XPROCESS (process)->infd, inchannel);
    XSETINT (XPROCESS (process)->outfd, outchannel);
! 
!   /* Previously we recorded the tty descriptor used in the subprocess.
!      It was only used for getting the foreground tty process, so now
!      we just reopen the device (see emacs_get_tty_pgrp) as this is
!      more portable (see USG_SUBTTY_WORKS above).  */
! 
    XPROCESS (process)->pty_flag = (pty_flag ? Qt : Qnil);
    XPROCESS (process)->status = Qrun;
    setup_process_coding_systems (process);
***************
*** 2044,2050 ****
        EMACS_SET_SECS_USECS (offset, 1, 0);
        timer = start_atimer (ATIMER_RELATIVE, offset, create_process_1, 0);
  
-       XPROCESS (process)->subtty = Qnil;
        if (forkin >= 0)
          emacs_close (forkin);
  
--- 2045,2050 ----
***************
*** 5107,5112 ****
--- 5107,5139 ----
    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.
***************
*** 5117,5123 ****
  {
    /* 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;
  
--- 5144,5150 ----
  {
    /* 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;
  
***************
*** 5131,5142 ****
      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;
--- 5158,5164 ----
      error ("Process %s is not active",
           SDATA (p->name));
  
!   gid = emacs_get_tty_pgrp (p);
  
    if (gid == XFASTINT (p->pid))
      return Qnil;
***************
*** 5288,5306 ****
         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.
--- 5310,5322 ----
         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.
***************
*** 5362,5368 ****
    /* 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);
--- 5378,5387 ----
    /* 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);




reply via email to

[Prev in Thread] Current Thread [Next in Thread]