summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Djärv <jan.h.d@swipnet.se>2003-02-23 18:57:54 +0000
committerJan Djärv <jan.h.d@swipnet.se>2003-02-23 18:57:54 +0000
commitdf1cd29a28226d0256c50cacdc339c15ec13b1d0 (patch)
treedef2726be4b7df6cf5623e01cf2872e96103ae98
parentda6da2f97f42617cf6115f30ef49bb398e3a4f73 (diff)
downloademacs-df1cd29a28226d0256c50cacdc339c15ec13b1d0.tar.gz
Workaround for when TIOCSIGSEND fails.
-rw-r--r--src/ChangeLog7
-rw-r--r--src/process.c54
2 files changed, 44 insertions, 17 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index d1510fe055d..b71df9b4c81 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,10 @@
+2003-02-23 Jan Dj,Ad(Brv <jan.h.d@swipnet.se>
+
+ * process.c (emacs_get_tty_pgrp): New function.
+ (Fprocess_running_child_p, process_send_signal): Call
+ emacs_get_tty_pgrp instead of ioctl.
+ (process_send_signal): Call EMACS_KILLPG if ioctl TIOCSIGSEND fails.
+
2003-02-19 Juanma Barranquero <lektu@terra.es>
* s/hpux10.h (HPUX10): Define it just once.
diff --git a/src/process.c b/src/process.c
index a89c05aa790..a59737dc139 100644
--- a/src/process.c
+++ b/src/process.c
@@ -3572,6 +3572,33 @@ Output from processes can arrive in between bunches.")
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\
@@ -3582,7 +3609,7 @@ return t unconditionally.")
{
/* Initialize in case ioctl doesn't exist or gives an error,
in a way that will cause returning t. */
- int gid = 0;
+ int gid;
Lisp_Object proc;
struct Lisp_Process *p;
@@ -3596,12 +3623,7 @@ return t unconditionally.")
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 ) */
+ gid = emacs_get_tty_pgrp (p);
if (gid == XFASTINT (p->pid))
return Qnil;
@@ -3748,19 +3770,14 @@ process_send_signal (process, signo, current_group, nomsg)
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);
+ gid = emacs_get_tty_pgrp (p);
#ifdef pfa
- if (err == -1)
- gid = - XFASTINT (p->pid);
+ if (gid == -1)
+ gid = - XFASTINT (p->pid);
#endif /* ! defined (pfa) */
- }
+
if (gid == -1)
no_pgrp = 1;
else
@@ -3822,7 +3839,10 @@ process_send_signal (process, signo, current_group, nomsg)
/* gid may be a pid, or minus a pgrp's number */
#ifdef TIOCSIGSEND
if (!NILP (current_group))
- ioctl (XINT (p->infd), TIOCSIGSEND, signo);
+ {
+ if (ioctl (XINT (p->infd), TIOCSIGSEND, signo) == -1)
+ EMACS_KILLPG (-gid, signo);
+ }
else
{
gid = - XFASTINT (p->pid);