Diss Contr Term PATCH

トップ ページ
このメッセージを削除
このメッセージに返信
著者: Neal Becker
日付:  
To: exim-users
題目: Diss Contr Term PATCH
Here is a tentative patch to dissasociate for the controlling tty when
in daemon mode. No attempt was made to autoconfigure. As it stands,
you need to define either HAVE_SETSID or HAVE_TIOCNOTTY.

How does this look?

--- src/daemon.c    1996/04/19 13:36:04    1.1
+++ src/daemon.c    1996/04/19 13:39:33
@@ -8,7 +8,7 @@



 #include "exim.h"
-
+#include <sys/ioctl.h>        /* for TIOCNOTTY */



/*************************************************
@@ -368,10 +368,25 @@

 if (debug_level == 0 && !debug_trace_memory)
   {
+    int i;
   int pid = fork();
   if (pid < 0) log_write(LOG_PANIC_DIE, "fork() failed: %s", strerror(errno));
   if (pid > 0) exit(EXIT_SUCCESS);      /* in parent process, just exit */
   }
+
+                /* Dissociate from controlling tty */
+#ifdef HAVE_SETSID
+    (void)setsid();
+#else
+#ifdef HAVE_TIOCNOTTY
+    if ((i = open("/dev/tty", O_RDWR)) >= 0) {
+      if (ioctl(i, TIOCNOTTY, (char *)NULL) < 0)
+    log_write (LOG_PANIC_DIE, "%s cant ioctl(TIOCNOTTY) %s", LogName, strerror(errno));
+      if (close(i) < 0)
+    log_write (LOG_PANIC_DIE, "%s cant close /dev/tty %s", LogName, strerror(errno));
+    }
+#endif    /* HAVE_TIOCNOTTY */
+#endif /* HAVE_SETSID */



 /* If SMTP listening is requested, set up a socket on the SMTP port or
--- OS/os.h-HP-UX    1996/04/19 13:36:46    1.1
+++ OS/os.h-HP-UX    1996/04/19 13:36:53
@@ -2,6 +2,7 @@


 #define F_FREESP     O_TRUNC
 #define NEED_H_ERRNO 1
+#define HAVE_SETSID
 typedef struct flock flock_t;


/* End */