zsh-workers
 help / color / mirror / code / Atom feed
* Spring patch clean-up: HAVE_BROKEN_TCSETPGRP and backgrounded ./configure
@ 2004-05-28 23:55 Philippe Troin
  2004-06-02  9:25 ` Peter Stephenson
  2004-06-08 13:27 ` Peter Stephenson
  0 siblings, 2 replies; 5+ messages in thread
From: Philippe Troin @ 2004-05-28 23:55 UTC (permalink / raw)
  To: zsh-workers

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

This patch was discussed here:

http://www.zsh.org/cgi-bin/mla/redirect?usernumber=6812

Executive summary:

 1. some people have complained that running zsh's configure in the
    background hangs when checking for broken tcsetpgrp().

 2. some people have complained that if they run zsh's configure a
    some magic build script that does not have a controlling tty, then
    zsh is built incorrectly (tcsetpgrp() is then assumed broken).

 - this patch takes care of #1 by blocking SIGTTOU during the duration
   of the "checking for broken tcsetpgrp" test.

 - this patch takes care of #2 by adding a new ./configure option
   --with-tcsetpgrp, which behaves this way:

     * under normal circumstances (running with a ctty), this option
       is not needed.

     * ./configure will abort and report "Try running configure with
       --with-tcsetpgrp or --without-tcsetpgrp" if this option is
       needed (running WITHOUT a ctty).

     * when --with-tcsetpgrp is specified, the "checking for broken
       tcsetpgrp" test is skipped.

     * when --without-tcsetpgrp is specified, the "checking for broken
       tcsetpgrp" test is skipped and BROKEN_TCSETPGRP is AC_DEFINED.

Shall we consider this for inclusion?

Phil.

Patch against latest CVS sources:

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

Index: configure.ac
===================================================================
RCS file: /cvsroot/zsh/zsh/configure.ac,v
retrieving revision 1.17
diff -b -u -r1.17 configure.ac
--- configure.ac	6 Apr 2004 09:25:17 -0000	1.17
+++ configure.ac	28 May 2004 23:02:59 -0000
@@ -1766,24 +1766,53 @@
 dnl -----------
 AH_TEMPLATE([BROKEN_TCSETPGRP],
 [Define to 1 if tcsetpgrp() doesn't work, ie BeOS R4.51.])
-if test -t 0 && test $ac_cv_func_tcsetpgrp = yes; then
+AC_ARG_WITH(tcsetpgrp,
+[  --with-tcsetpgrp        assumes that tcsetpgrp() exists and works correctly],[
+case "x$withval" in
+    xyes) zsh_working_tcsetpgrp=yes;;
+    xno)  zsh_working_tcsetpgrp=no;;
+    *)    AC_ERROR([please use --with-tcsetpgrp=yes or --with-tcsetpgrp=no]);;
+esac],[zsh_working_tcsetpgrp=check])
+if test "x$ac_cv_func_tcsetpgrp" = xyes; then
+case "x$zsh_working_tcsetpgrp" in
+  xcheck)
+    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_MSG_ERROR([no controlling tty
+Try running configure with --with-tcsetpgrp or --without-tcsetpgrp]);;
+      *)      AC_MSG_ERROR([unexpected return status]);;
+    esac
+    trap - SIGTTOU > /dev/null 2>&1 || :
+    ;;
+  xyes) :;;
+  xno)  AC_DEFINE(BROKEN_TCSETPGRP);;
+  *)    AC_MSG_ERROR([unexpected value zsh_working_tcsetpgrp=$zsh_working_tcsetpgrp]);;
+esac
 fi
 
 dnl -----------

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

* Re: Spring patch clean-up: HAVE_BROKEN_TCSETPGRP and backgrounded ./configure
  2004-05-28 23:55 Spring patch clean-up: HAVE_BROKEN_TCSETPGRP and backgrounded ./configure Philippe Troin
@ 2004-06-02  9:25 ` Peter Stephenson
  2004-06-02  9:43   ` Philippe Troin
  2004-06-08 13:27 ` Peter Stephenson
  1 sibling, 1 reply; 5+ messages in thread
From: Peter Stephenson @ 2004-06-02  9:25 UTC (permalink / raw)
  To: zsh-workers

Philippe Troin wrote:
> Shall we consider this for inclusion?

I haven't actually tried this, but it looks reasonable.

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK                          Tel: +44 (0)1223 692070


**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.

www.mimesweeper.com
**********************************************************************


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

* Re: Spring patch clean-up: HAVE_BROKEN_TCSETPGRP and backgrounded ./configure
  2004-06-02  9:25 ` Peter Stephenson
@ 2004-06-02  9:43   ` Philippe Troin
  0 siblings, 0 replies; 5+ messages in thread
From: Philippe Troin @ 2004-06-02  9:43 UTC (permalink / raw)
  To: Peter Stephenson; +Cc: zsh-workers

Peter Stephenson <pws@csr.com> writes:

> Philippe Troin wrote:
> > Shall we consider this for inclusion?
> 
> I haven't actually tried this, but it looks reasonable.

Last time I've tried, it worked, I promise :-)

Things to test:

  ./configure                - should work

  ./configure &              - should work and not hang

  ./configure < /dev/null >& /dev/null
                             - should detect HAVE_BROKEN_TCSETPGRP
                               correctly (used to assume
                               !HAVE_BROKEN_TCSETPGRP if test ! -t 0)

  setsid ./configure         - run without a tty, should complain and
                               request to use --with[out]-tcsetpgrp

  echo ./configure | at now  - same as above

Also, the part that I have not tested: run all the above on a host for
which HAVE_BROKEN_TCSETPGRP is true...  Which arch, I dunno... BeOS maybe?

Phil.


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

* Re: Spring patch clean-up: HAVE_BROKEN_TCSETPGRP and backgrounded ./configure
  2004-05-28 23:55 Spring patch clean-up: HAVE_BROKEN_TCSETPGRP and backgrounded ./configure Philippe Troin
  2004-06-02  9:25 ` Peter Stephenson
@ 2004-06-08 13:27 ` Peter Stephenson
  2004-06-08 15:05   ` Philippe Troin
  1 sibling, 1 reply; 5+ messages in thread
From: Peter Stephenson @ 2004-06-08 13:27 UTC (permalink / raw)
  To: zsh-workers

I'll commit this patch with the following additional information.

Index: INSTALL
===================================================================
RCS file: /cvsroot/zsh/zsh/INSTALL,v
retrieving revision 1.14
diff -u -r1.14 INSTALL
--- INSTALL	4 Mar 2004 14:03:48 -0000	1.14
+++ INSTALL	8 Jun 2004 13:26:12 -0000
@@ -385,6 +385,12 @@
 default as on some systems non-standard headers (in particular AIX) are
 required.  A direct fix for that problem would be appreciated.
 
+A test for the function tcsetpgrp is turned on by default.  The test needs
+to run the function to determine if the implementation is usable. However,
+this can cause problems when configure is run without a terminal.  To avoid
+this, use --with-tcsetpgrp or --without-tcsetpgrp to tell configure whether
+the function should be used.
+
 Options For Configure
 ---------------------
 
-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK                          Tel: +44 (0)1223 692070


**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.

www.mimesweeper.com
**********************************************************************


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

* Re: Spring patch clean-up: HAVE_BROKEN_TCSETPGRP and backgrounded ./configure
  2004-06-08 13:27 ` Peter Stephenson
@ 2004-06-08 15:05   ` Philippe Troin
  0 siblings, 0 replies; 5+ messages in thread
From: Philippe Troin @ 2004-06-08 15:05 UTC (permalink / raw)
  To: Peter Stephenson; +Cc: zsh-workers

Peter Stephenson <pws@csr.com> writes:

> I'll commit this patch with the following additional information.

Thanks Peter.

Nitpicking:
 
> +A test for the function tcsetpgrp is turned on by default.  The test needs
> +to run the function to determine if the implementation is usable. However,
> +this can cause problems when configure is run without a terminal.  To avoid
> +this, use --with-tcsetpgrp or --without-tcsetpgrp to tell configure whether
> +the function should be used.
> +

should be replaced by:

A test for the function tcsetpgrp is turned on by default.  The test
needs to run the function to determine if the implementation is
usable. However, this can cause problems when configure is run without
a controlling terminal (eg. from cron).  To avoid this, use
--with-tcsetpgrp or --without-tcsetpgrp to tell configure whether the
function should be used.

One can run with on a terminal without it being the controlling
terminal. Like when doing clone /dev/pts/<n>, the cloned zsh is
running on a tty, but has no ctty.

Phil.


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

end of thread, other threads:[~2004-06-08 15:05 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-05-28 23:55 Spring patch clean-up: HAVE_BROKEN_TCSETPGRP and backgrounded ./configure Philippe Troin
2004-06-02  9:25 ` Peter Stephenson
2004-06-02  9:43   ` Philippe Troin
2004-06-08 13:27 ` Peter Stephenson
2004-06-08 15:05   ` 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).