* configure.in: increase library patchlevel
authorIon Badulescu <ib42@cs.columbia.edu>
Sat, 28 Dec 2002 22:28:56 +0000 (22:28 +0000)
committerIon Badulescu <ib42@cs.columbia.edu>
Sat, 28 Dec 2002 22:28:56 +0000 (22:28 +0000)
* libamu/xutil.c (amu_release_controlling_tty): close and reopen
file descriptors 0,1,2 before calling setsid()

ChangeLog
configure.in
libamu/xutil.c

index d3db02851614b1631f89533b3677edf4e3eeb329..c537a316c015562a165cf1777693083ef29d04f0 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2002-12-28  Ion Badulescu  <ionut@moisil.badula.org>
+
+       * configure.in: increase library patchlevel
+
+       * libamu/xutil.c (amu_release_controlling_tty): close and reopen
+       file descriptors 0,1,2 before calling setsid()
+
 2002-12-27  Erez Zadok  <ezk@cs.sunysb.edu>
 
        * updated copyright year to 2003 on all files
index e3d5158fc93505b7580480925c1905d8058c2049..84da5088c89f54cacf5e9f130b861c669b245490 100644 (file)
@@ -53,7 +53,7 @@ AH_BOTTOM([
 dnl
 dnl AC_CONFIG_AUX_DIR(m4)
 AC_PREREQ(2.52)
-AC_REVISION($Revision: 1.44 $)
+AC_REVISION($Revision: 1.45 $)
 AC_COPYRIGHT([Copyright (c) 1997-2003 Erez Zadok])
 dnl find out system type
 AC_MSG_NOTICE(*** SYSTEM TYPES ***)
@@ -90,7 +90,7 @@ dnl last version info was 4.1.2 (am-utils-6.0.4)
 dnl
 dnl We increase the minor number for am-utils-6.1, because it has a new API
 dnl (get_server_pid) but can be used without problems by am-utils-6.0.3+.
-LIBTOOL_LDFLAGS="-version-info 5:2:3"
+LIBTOOL_LDFLAGS="-version-info 5:3:3"
 AC_SUBST(LIBTOOL_LDFLAGS)
 dnl ======================================================================
 
index 19e16de4e23f89eef240be48be2f917a749f3087..92084ef25954fcbe8f707c7616604fbaf53168a0 100644 (file)
@@ -37,7 +37,7 @@
  * SUCH DAMAGE.
  *
  *
- * $Id: xutil.c,v 1.28 2002/12/27 22:44:11 ezk Exp $
+ * $Id: xutil.c,v 1.29 2002/12/28 22:28:57 ib42 Exp $
  *
  */
 
@@ -881,24 +881,14 @@ amu_release_controlling_tty(void)
 #endif /* TIOCNOTTY */
   int tempfd;
 
-#ifdef HAVE_SETSID
-  /* XXX: one day maybe use vhangup(2) */
-  if (setsid() < 0) {
-    plog(XLOG_WARNING, "Could not release controlling tty using setsid(): %m");
-  } else {
-    plog(XLOG_INFO, "released controlling tty using setsid()");
-    return;
-  }
-#endif /* HAVE_SETSID */
-
   /*
    * In daemon mode, leaving open file descriptors to terminals or pipes
    * can be a really bad idea.
    * Case in point: the redhat startup script calls us through their 'initlog'
-   * program, which exits as soon as the original amd process exits. If, at some
-   * point, a misbehaved library function decides to print something to the screen,
-   * we get a SIGPIPE and die.
-   * More precisely: NIS libc functions will attempt to print to stderr
+   * program, which exits as soon as the original amd process exits. If,
+   * at some point, a misbehaved library function decides to print something
+   * to the screen, we get a SIGPIPE and die.
+   * And guess what: NIS glibc functions will attempt to print to stderr
    * "YPBINDPROC_DOMAIN: Domain not bound" if ypbind is running but can't find
    * a ypserver.
    *
@@ -913,6 +903,16 @@ amu_release_controlling_tty(void)
   fflush(stderr); close(2); dup2(tempfd, 2);
   close(tempfd);
 
+#ifdef HAVE_SETSID
+  /* XXX: one day maybe use vhangup(2) */
+  if (setsid() < 0) {
+    plog(XLOG_WARNING, "Could not release controlling tty using setsid(): %m");
+  } else {
+    plog(XLOG_INFO, "released controlling tty using setsid()");
+    return;
+  }
+#endif /* HAVE_SETSID */
+
 #ifdef TIOCNOTTY
   fd = open("/dev/tty", O_RDWR);
   if (fd < 0) {