Useful functions (u_daemon and versioncmp) moved to mLib.
[tripe] / common / util.c
index 4b32985..1745655 100644 (file)
 #include <stdlib.h>
 #include <string.h>
 
-#include <sys/types.h>
-#include <unistd.h>
-#include <fcntl.h>
-
 #include <mLib/dstr.h>
 
 #include "util.h"
 
-#include <sys/ioctl.h>
-
 /*----- Main code ---------------------------------------------------------*/
 
 /* --- @u_quotify@ --- *
@@ -73,51 +67,4 @@ void u_quotify(dstr *d, const char *p)
   }
 }
 
-/* --- @u_detach@ --- *
- *
- * Arguments:  ---
- *
- * Returns:    ---
- *
- * Use:                Detaches from the current terminal and ensures it can never
- *             acquire a new one.  Calls @fork@.
- */
-
-void u_detach(void)
-{
-#ifdef TIOCNOTTY
-  {
-    int fd;
-    if ((fd = open("/dev/tty", O_RDONLY)) >= 0) {
-      ioctl(fd, TIOCNOTTY);
-      close(fd);
-    }
-  }
-#endif
-  setsid();
-  if (fork() > 0)
-    _exit(0);
-}
-
-/* --- @u_daemon@ --- *
- *
- * Arguments:  ---
- *
- * Returns:    Zero if OK, nonzero on failure.
- *
- * Use:                Becomes a daemon.
- */
-
-int u_daemon(void)
-{
-  pid_t kid;
-
-  if ((kid = fork()) < 0)
-    return (-1);
-  if (kid)
-    _exit(0);
-  u_detach();
-  return (0);
-}
-
 /*----- That's all, folks -------------------------------------------------*/