3572 |
return Qnil; |
return Qnil; |
3573 |
} |
} |
3574 |
|
|
3575 |
|
/* Return the foreground process group for the tty/pty that |
3576 |
|
the process P uses. */ |
3577 |
|
static int |
3578 |
|
emacs_get_tty_pgrp (p) |
3579 |
|
struct Lisp_Process *p; |
3580 |
|
{ |
3581 |
|
int gid = -1; |
3582 |
|
|
3583 |
|
#ifdef TIOCGPGRP |
3584 |
|
if (ioctl (XINT (p->infd), TIOCGPGRP, &gid) == -1 && ! NILP (p->tty_name)) |
3585 |
|
{ |
3586 |
|
int fd; |
3587 |
|
/* Some OS:es (Solaris 8/9) does not allow TIOCGPGRP from the |
3588 |
|
master side. Try the slave side. */ |
3589 |
|
fd = emacs_open (XSTRING (p->tty_name)->data, O_RDONLY, 0); |
3590 |
|
|
3591 |
|
if (fd != -1) |
3592 |
|
{ |
3593 |
|
ioctl (fd, TIOCGPGRP, &gid); |
3594 |
|
emacs_close (fd); |
3595 |
|
} |
3596 |
|
} |
3597 |
|
#endif /* defined (TIOCGPGRP ) */ |
3598 |
|
|
3599 |
|
return gid; |
3600 |
|
} |
3601 |
|
|
3602 |
DEFUN ("process-running-child-p", Fprocess_running_child_p, |
DEFUN ("process-running-child-p", Fprocess_running_child_p, |
3603 |
Sprocess_running_child_p, 0, 1, 0, |
Sprocess_running_child_p, 0, 1, 0, |
3604 |
"Return t if PROCESS has given the terminal to a child.\n\ |
"Return t if PROCESS has given the terminal to a child.\n\ |
3609 |
{ |
{ |
3610 |
/* Initialize in case ioctl doesn't exist or gives an error, |
/* Initialize in case ioctl doesn't exist or gives an error, |
3611 |
in a way that will cause returning t. */ |
in a way that will cause returning t. */ |
3612 |
int gid = 0; |
int gid; |
3613 |
Lisp_Object proc; |
Lisp_Object proc; |
3614 |
struct Lisp_Process *p; |
struct Lisp_Process *p; |
3615 |
|
|
3623 |
error ("Process %s is not active", |
error ("Process %s is not active", |
3624 |
XSTRING (p->name)->data); |
XSTRING (p->name)->data); |
3625 |
|
|
3626 |
#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 ) */ |
|
3627 |
|
|
3628 |
if (gid == XFASTINT (p->pid)) |
if (gid == XFASTINT (p->pid)) |
3629 |
return Qnil; |
return Qnil; |
3770 |
But, TIOCGPGRP does not work on E50 ;-P works fine on E60" |
But, TIOCGPGRP does not work on E50 ;-P works fine on E60" |
3771 |
His patch indicates that if TIOCGPGRP returns an error, then |
His patch indicates that if TIOCGPGRP returns an error, then |
3772 |
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; |
|
3773 |
|
|
3774 |
if (!NILP (p->subtty)) |
gid = emacs_get_tty_pgrp (p); |
|
err = ioctl (XFASTINT (p->subtty), TIOCGPGRP, &gid); |
|
|
else |
|
|
err = ioctl (XINT (p->infd), TIOCGPGRP, &gid); |
|
3775 |
|
|
3776 |
#ifdef pfa |
#ifdef pfa |
3777 |
if (err == -1) |
if (gid == -1) |
3778 |
gid = - XFASTINT (p->pid); |
gid = - XFASTINT (p->pid); |
3779 |
#endif /* ! defined (pfa) */ |
#endif /* ! defined (pfa) */ |
3780 |
} |
|
3781 |
if (gid == -1) |
if (gid == -1) |
3782 |
no_pgrp = 1; |
no_pgrp = 1; |
3783 |
else |
else |
3839 |
/* gid may be a pid, or minus a pgrp's number */ |
/* gid may be a pid, or minus a pgrp's number */ |
3840 |
#ifdef TIOCSIGSEND |
#ifdef TIOCSIGSEND |
3841 |
if (!NILP (current_group)) |
if (!NILP (current_group)) |
3842 |
ioctl (XINT (p->infd), TIOCSIGSEND, signo); |
{ |
3843 |
|
if (ioctl (XINT (p->infd), TIOCSIGSEND, signo) == -1) |
3844 |
|
EMACS_KILLPG (-gid, signo); |
3845 |
|
} |
3846 |
else |
else |
3847 |
{ |
{ |
3848 |
gid = - XFASTINT (p->pid); |
gid = - XFASTINT (p->pid); |