1782 |
chan_process[inchannel] = process; |
chan_process[inchannel] = process; |
1783 |
XSETINT (XPROCESS (process)->infd, inchannel); |
XSETINT (XPROCESS (process)->infd, inchannel); |
1784 |
XSETINT (XPROCESS (process)->outfd, outchannel); |
XSETINT (XPROCESS (process)->outfd, outchannel); |
1785 |
/* Record the tty descriptor used in the subprocess. */ |
|
1786 |
if (forkin < 0) |
/* Previously we recorded the tty descriptor used in the subprocess. |
1787 |
XPROCESS (process)->subtty = Qnil; |
It was only used for getting the foreground tty process, so now |
1788 |
else |
we just reopen the device (see emacs_get_tty_pgrp) as this is |
1789 |
XSETFASTINT (XPROCESS (process)->subtty, forkin); |
more portable (see USG_SUBTTY_WORKS above). */ |
1790 |
|
|
1791 |
XPROCESS (process)->pty_flag = (pty_flag ? Qt : Qnil); |
XPROCESS (process)->pty_flag = (pty_flag ? Qt : Qnil); |
1792 |
XPROCESS (process)->status = Qrun; |
XPROCESS (process)->status = Qrun; |
1793 |
setup_process_coding_systems (process); |
setup_process_coding_systems (process); |
2045 |
EMACS_SET_SECS_USECS (offset, 1, 0); |
EMACS_SET_SECS_USECS (offset, 1, 0); |
2046 |
timer = start_atimer (ATIMER_RELATIVE, offset, create_process_1, 0); |
timer = start_atimer (ATIMER_RELATIVE, offset, create_process_1, 0); |
2047 |
|
|
|
XPROCESS (process)->subtty = Qnil; |
|
2048 |
if (forkin >= 0) |
if (forkin >= 0) |
2049 |
emacs_close (forkin); |
emacs_close (forkin); |
2050 |
|
|
5107 |
return Qnil; |
return Qnil; |
5108 |
} |
} |
5109 |
|
|
5110 |
|
/* Return the foreground process group for the tty/pty that |
5111 |
|
the process P uses. */ |
5112 |
|
static int |
5113 |
|
emacs_get_tty_pgrp (p) |
5114 |
|
struct Lisp_Process *p; |
5115 |
|
{ |
5116 |
|
int gid = -1; |
5117 |
|
|
5118 |
|
#ifdef TIOCGPGRP |
5119 |
|
if (ioctl (XINT (p->infd), TIOCGPGRP, &gid) == -1 && ! NILP (p->tty_name)) |
5120 |
|
{ |
5121 |
|
int fd; |
5122 |
|
/* Some OS:es (Solaris 8/9) does not allow TIOCGPGRP from the |
5123 |
|
master side. Try the slave side. */ |
5124 |
|
fd = emacs_open (XSTRING (p->tty_name)->data, O_RDONLY, 0); |
5125 |
|
|
5126 |
|
if (fd != -1) |
5127 |
|
{ |
5128 |
|
ioctl (fd, TIOCGPGRP, &gid); |
5129 |
|
emacs_close (fd); |
5130 |
|
} |
5131 |
|
} |
5132 |
|
#endif /* defined (TIOCGPGRP ) */ |
5133 |
|
|
5134 |
|
return gid; |
5135 |
|
} |
5136 |
|
|
5137 |
DEFUN ("process-running-child-p", Fprocess_running_child_p, |
DEFUN ("process-running-child-p", Fprocess_running_child_p, |
5138 |
Sprocess_running_child_p, 0, 1, 0, |
Sprocess_running_child_p, 0, 1, 0, |
5139 |
doc: /* Return t if PROCESS has given the terminal to a child. |
doc: /* Return t if PROCESS has given the terminal to a child. |
5144 |
{ |
{ |
5145 |
/* Initialize in case ioctl doesn't exist or gives an error, |
/* Initialize in case ioctl doesn't exist or gives an error, |
5146 |
in a way that will cause returning t. */ |
in a way that will cause returning t. */ |
5147 |
int gid = 0; |
int gid; |
5148 |
Lisp_Object proc; |
Lisp_Object proc; |
5149 |
struct Lisp_Process *p; |
struct Lisp_Process *p; |
5150 |
|
|
5158 |
error ("Process %s is not active", |
error ("Process %s is not active", |
5159 |
SDATA (p->name)); |
SDATA (p->name)); |
5160 |
|
|
5161 |
#ifdef TIOCGPGRP |
gid = emacs_get_tty_pgrp (p); |
|
if (!NILP (p->subtty)) |
|
|
ioctl (XFASTINT (p->subtty), TIOCGPGRP, &gid); |
|
|
else |
|
|
ioctl (XINT (p->infd), TIOCGPGRP, &gid); |
|
|
#endif /* defined (TIOCGPGRP ) */ |
|
5162 |
|
|
5163 |
if (gid == XFASTINT (p->pid)) |
if (gid == XFASTINT (p->pid)) |
5164 |
return Qnil; |
return Qnil; |
5310 |
But, TIOCGPGRP does not work on E50 ;-P works fine on E60" |
But, TIOCGPGRP does not work on E50 ;-P works fine on E60" |
5311 |
His patch indicates that if TIOCGPGRP returns an error, then |
His patch indicates that if TIOCGPGRP returns an error, then |
5312 |
we should just assume that p->pid is also the process group id. */ |
we should just assume that p->pid is also the process group id. */ |
|
{ |
|
|
int err; |
|
5313 |
|
|
5314 |
if (!NILP (p->subtty)) |
gid = emacs_get_tty_pgrp (p); |
5315 |
err = ioctl (XFASTINT (p->subtty), TIOCGPGRP, &gid); |
|
5316 |
else |
if (gid == -1) |
5317 |
err = ioctl (XINT (p->infd), TIOCGPGRP, &gid); |
/* If we can't get the information, assume |
5318 |
|
the shell owns the tty. */ |
5319 |
if (err == -1) |
gid = XFASTINT (p->pid); |
|
/* If we can't get the information, assume |
|
|
the shell owns the tty. */ |
|
|
gid = XFASTINT (p->pid); |
|
|
} |
|
5320 |
|
|
5321 |
/* It is not clear whether anything really can set GID to -1. |
/* It is not clear whether anything really can set GID to -1. |
5322 |
Perhaps on some system one of those ioctls can or could do so. |
Perhaps on some system one of those ioctls can or could do so. |
5378 |
/* gid may be a pid, or minus a pgrp's number */ |
/* gid may be a pid, or minus a pgrp's number */ |
5379 |
#ifdef TIOCSIGSEND |
#ifdef TIOCSIGSEND |
5380 |
if (!NILP (current_group)) |
if (!NILP (current_group)) |
5381 |
ioctl (XINT (p->infd), TIOCSIGSEND, signo); |
{ |
5382 |
|
if (ioctl (XINT (p->infd), TIOCSIGSEND, signo) == -1) |
5383 |
|
EMACS_KILLPG (gid, signo); |
5384 |
|
} |
5385 |
else |
else |
5386 |
{ |
{ |
5387 |
gid = - XFASTINT (p->pid); |
gid = - XFASTINT (p->pid); |