X-Git-Url: https://git.distorted.org.uk/~mdw/tripe/blobdiff_plain/602cab72ea5bce19bebb170ca0344404a963d022..19dd2531cafe84927c845e548ec68587007f3ab2:/common/util.c?ds=sidebyside diff --git a/common/util.c b/common/util.c index 4b32985c..17456551 100644 --- a/common/util.c +++ b/common/util.c @@ -33,16 +33,10 @@ #include #include -#include -#include -#include - #include #include "util.h" -#include - /*----- 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 -------------------------------------------------*/