zsh-workers
 help / color / mirror / code / Atom feed
* [PATCH] allows configure to run in the background
@ 2003-11-25  3:51 Philippe Troin
  2003-11-25 20:36 ` Philippe Troin
  0 siblings, 1 reply; 2+ messages in thread
From: Philippe Troin @ 2003-11-25  3:51 UTC (permalink / raw)
  To: zsh-workers

[-- Attachment #1: Type: text/plain, Size: 224 bytes --]

The checking "if tcsetpgrp() actually works" configure test stops the
configure script if it is ran in the background. The enclose patch
prevents this from happening by ignoring SIGTTOU for the duration of
this test.

Phil.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: zsh-bgconfigure.patch --]
[-- Type: text/x-patch, Size: 744 bytes --]

Index: zshconfig.ac
===================================================================
RCS file: /cvsroot/zsh/zsh/zshconfig.ac,v
retrieving revision 1.42
diff -b -u -r1.42 zshconfig.ac
--- zshconfig.ac	13 Nov 2003 14:34:34 -0000	1.42
+++ zshconfig.ac	25 Nov 2003 03:38:29 -0000
@@ -1577,6 +1577,7 @@
 dnl for instance, BeOS R4.51 does not support it yet
 dnl -----------
 if test -t 0 && test $ac_cv_func_tcsetpgrp = yes; then
+    trap "" SIGTTOU > /dev/null 2>&1 || :
     AC_CACHE_CHECK(if tcsetpgrp() actually works,
     zsh_cv_sys_tcsetpgrp,
     [AC_TRY_RUN([
@@ -1594,6 +1595,7 @@
     if test $zsh_cv_sys_tcsetpgrp = no; then
       AC_DEFINE(BROKEN_TCSETPGRP)
     fi
+    trap - SIGTTOU > /dev/null 2>&1 || :
 fi
 
 dnl -----------

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] allows configure to run in the background
  2003-11-25  3:51 [PATCH] allows configure to run in the background Philippe Troin
@ 2003-11-25 20:36 ` Philippe Troin
  0 siblings, 0 replies; 2+ messages in thread
From: Philippe Troin @ 2003-11-25 20:36 UTC (permalink / raw)
  To: zsh-workers

[-- Attachment #1: Type: text/plain, Size: 1479 bytes --]

Philippe Troin <phil@fifi.org> writes:

> The checking "if tcsetpgrp() actually works" configure test stops the
> configure script if it is ran in the background. The enclose patch
> prevents this from happening by ignoring SIGTTOU for the duration of
> this test.

This is a second spin on the same idea, following up on comments from
Jens Petersen <petersen@redhat.com> in <m3d6bgq2tk.wl%petersen@redhat.com>.

Extra stuff taken care of:

 - works if stdin is redirected (opens /dev/tty instead of relying on stdin)

 - detects if ran without controlling tty, and aborts

Stuff taken care of with the first patch, included with this patch:

 - does not stop if ran on the background.

I think this patch will address all of Jens's concerns. There are
still some quirks, but I believe they will only show up very
infrequently:

 - configure completely fails if ran without a controlling tty. Should
   not be a major problem, processes running the background still have
   a controlling tty. Running without a ctty only happens when running
   from cron or some other batch facilities. Anybody doing that?

 - there still is a tiny race window if the shell decides to switch
   the foreground process between the tcgetpgrp() and tcsetpgrp()
   calls.

It is probably better to go this route rather than running this
particular configure test on its own pty: this would add a lot of very
platform specific cruft to the test itself, and configure is supposed
to be robust.

Phil.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: zsh-bgconfigure-2.patch --]
[-- Type: text/x-patch, Size: 1642 bytes --]

Index: zshconfig.ac
===================================================================
RCS file: /cvsroot/zsh/zsh/zshconfig.ac,v
retrieving revision 1.42
diff -b -u -r1.42 zshconfig.ac
--- zshconfig.ac	13 Nov 2003 14:34:34 -0000	1.42
+++ zshconfig.ac	25 Nov 2003 20:16:35 -0000
@@ -1576,24 +1576,38 @@
 dnl if found tcsetpgrp, test to see if it actually works
 dnl for instance, BeOS R4.51 does not support it yet
 dnl -----------
-if test -t 0 && test $ac_cv_func_tcsetpgrp = yes; then
+if test $ac_cv_func_tcsetpgrp = yes; then
+    trap "" SIGTTOU > /dev/null 2>&1 || :
     AC_CACHE_CHECK(if tcsetpgrp() actually works,
     zsh_cv_sys_tcsetpgrp,
     [AC_TRY_RUN([
 #include <sys/types.h>
 #include <unistd.h>
+#include <fcntl.h>
 main() {
+    int fd;
     int ret;
-    ret=tcsetpgrp(0, tcgetpgrp(0));
-    exit(ret<0);
+    fd=open("/dev/tty", O_RDWR);
+    if (fd < 0) exit(2);
+    ret=tcsetpgrp(fd, tcgetpgrp(fd));
+    if (ret < 0) exit(1);
+    exit(0);
 }
 ],
-      zsh_cv_sys_tcsetpgrp=yes,
-      zsh_cv_sys_tcsetpgrp=no,
-      zsh_cv_sys_tcsetpgrp=yes)])
-    if test $zsh_cv_sys_tcsetpgrp = no; then
-      AC_DEFINE(BROKEN_TCSETPGRP)
-    fi
+      zsh_cv_sys_tcsetpgrp=yes, [
+case $? in
+    1) zsh_cv_sys_tcsetpgrp=no;;
+    2) zsh_cv_sys_tcsetpgrp=notty;;
+    *) zsh_cv_sys_tcsetpgrp=error;;
+esac
+      ], zsh_cv_sys_tcsetpgrp=yes)])
+    case "x$zsh_cv_sys_tcsetpgrp" in
+      xno)    AC_DEFINE(BROKEN_TCSETPGRP);;
+      xyes)   :;;
+      xnotty) AC_ERROR([no controlling tty]);;
+      *)      AC_ERROR([unexpected return status]);;
+    esac
+    trap - SIGTTOU > /dev/null 2>&1 || :
 fi
 
 dnl -----------

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2003-11-25 20:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-11-25  3:51 [PATCH] allows configure to run in the background Philippe Troin
2003-11-25 20:36 ` Philippe Troin

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).