X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~mdw/git/tripe/blobdiff_plain/e6b06b6b61b4b877937d4a56ba704d3f18154dc2..786989941b7b4504f0234c4a318f929802e981ad:/util.c diff --git a/util.c b/util.c deleted file mode 100644 index ceeb0bd5..00000000 --- a/util.c +++ /dev/null @@ -1,93 +0,0 @@ -/* -*-c-*- - * - * $Id: util.c,v 1.3 2004/04/08 01:36:17 mdw Exp $ - * - * Utilities for the client and the server - * - * (c) 2001 Straylight/Edgeware - */ - -/*----- Licensing notice --------------------------------------------------* - * - * This file is part of Trivial IP Encryption (TrIPE). - * - * TrIPE is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * TrIPE is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with TrIPE; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -/*----- Header files ------------------------------------------------------*/ - -#include -#include -#include -#include - -#include -#include -#include - -#include "util.h" - -#include - -/*----- Main code ---------------------------------------------------------*/ - -/* --- @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 -------------------------------------------------*/