2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these libraries and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
24 * (c) Copyright 1993, 1994 Hewlett-Packard Company *
25 * (c) Copyright 1993, 1994 International Business Machines Corp. *
26 * (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
27 * (c) Copyright 1993, 1994 Novell, Inc. *
30 * xdm - display manager daemon
32 * $TOG: daemon.c /main/5 1998/04/06 13:21:16 mgreess $
34 * Copyright 1988 Massachusetts Institute of Technology
36 * Permission to use, copy, modify, and distribute this software and its
37 * documentation for any purpose and without fee is hereby granted, provided
38 * that the above copyright notice appear in all copies and that both that
39 * copyright notice and this permission notice appear in supporting
40 * documentation, and that the name of M.I.T. not be used in advertising or
41 * publicity pertaining to distribution of the software without specific,
42 * written prior permission. M.I.T. makes no representations about the
43 * suitability of this software for any purpose. It is provided "as is"
44 * without express or implied warranty.
46 * Author: Keith Packard, MIT X Consortium
50 #include <sys/ioctl.h>
52 #include <sys/ptyio.h>
68 * fork so that the process goes into the background automatically. Also
69 * has a nice side effect of having the child process get inherited by
73 if (fork ()) /* if parent */
74 exit (0); /* then no more work to do */
77 * Close standard file descriptors and get rid of controlling tty
80 #if defined(SYSV) || defined (SVR4) || defined(__linux__)
83 setpgrp (0, getpid());
90 if ((i = open ("/dev/tty", O_RDWR)) >= 0) { /* did open succeed? */
91 #if defined(SYSV) && defined(TIOCTTY)
93 (void) ioctl (i, TIOCTTY, &zero);
95 (void) ioctl (i, TIOCNOTTY, (char *) 0); /* detach, BSD style */
101 * Set up the standard file descriptors.
103 (void) open ("/", O_RDONLY); /* root inode already in core */