From f4092abdf94af6a99aff944d6264bc1284e8bdd4 Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Mon, 10 Oct 2011 17:43:39 +0200 Subject: Imported nx-X11-3.1.0-1.tar.gz Summary: Imported nx-X11-3.1.0-1.tar.gz Keywords: Imported nx-X11-3.1.0-1.tar.gz into Git repository --- .../Xserver/hw/xfree86/os-support/bsdi/bsdi_init.c | 156 +++++++++++++++++++++ 1 file changed, 156 insertions(+) create mode 100644 nx-X11/programs/Xserver/hw/xfree86/os-support/bsdi/bsdi_init.c (limited to 'nx-X11/programs/Xserver/hw/xfree86/os-support/bsdi/bsdi_init.c') diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/bsdi/bsdi_init.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/bsdi/bsdi_init.c new file mode 100644 index 000000000..5a166ed26 --- /dev/null +++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/bsdi/bsdi_init.c @@ -0,0 +1,156 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsdi/bsdi_init.c,v 3.5.4.2 1998/06/05 16:23:08 dawes Exp $ */ +/* + * Copyright 1992 by Rich Murphey + * Copyright 1993 by David Wexelblat + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the names of Rich Murphey and David Wexelblat + * not be used in advertising or publicity pertaining to distribution of + * the software without specific, written prior permission. Rich Murphey and + * David Wexelblat make no representations about the suitability of this + * software for any purpose. It is provided "as is" without express or + * implied warranty. + * + * RICH MURPHEY AND DAVID WEXELBLAT DISCLAIM ALL WARRANTIES WITH REGARD TO + * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS, IN NO EVENT SHALL RICH MURPHEY OR DAVID WEXELBLAT BE LIABLE FOR + * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER + * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF + * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + */ +/* $XConsortium: bsdi_init.c /main/5 1996/02/21 17:51:15 kaleb $ */ + +#ifdef HAVE_XORG_CONFIG_H +#include +#endif + +#include +#include +#include "input.h" +#include "scrnintstr.h" + +#include "compiler.h" + +#include +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86_OSlib.h" + +extern Bool RunFromSmartParent; + +static Bool KeepTty = FALSE; + +#if BSD >= 199306 +static void +NonBlockConsoleOff() +{ + register int i; + + i = fcntl(2, F_GETFL, 0); + if (i >= 0) + (void) fcntl(2, F_SETFL, i & ~FNDELAY); +} +#endif + +void +xf86OpenConsole() +{ + int i, fd; + + if (serverGeneration == 1) + { + /* check if we're run with euid==0 */ + if (geteuid() != 0) + { + FatalError("xf86OpenConsole: Server must be suid root\n"); + } + + if (!KeepTty) + { +#if BSD >= 199306 + if (RunFromSmartParent) { + if (atexit(NonBlockConsoleOff)) + xf86Msg(X_WARNING, + "InitOutput: can't register NBIO exit handler\n"); + i = fcntl(2, F_GETFL, 0); + if (i >= 0) + i = fcntl(2, F_SETFL, i | FNDELAY); + if (i < 0) + xf86Msg(X_WARNING, + "InitOutput: can't put stderr in non-block mode\n"); + } +#else + /* + * detaching the controlling tty solves problems of kbd character + * loss. This is not interesting for CO driver, because it is + * exclusive. + */ + setpgrp(0, getpid()); + if ((i = open("/dev/tty",O_RDWR)) >= 0) + { + ioctl(i,TIOCNOTTY,(char *)0); + close(i); + } +#endif + } + + if ((xf86Info.consoleFd = open("/dev/kbd", O_RDWR|O_NDELAY,0)) < 0) + { + FatalError("xf86OpenConsole: Cannot open /dev/kbd (%s)\n", + strerror(errno)); + } + if ((xf86Info.screenFd = open("/dev/vga", O_RDWR|O_NDELAY,0)) < 0) + { + FatalError("xf86OpenConsole: Cannot open /dev/vga (%s)\n", + strerror(errno)); + } + + if (ioctl(xf86Info.consoleFd, PCCONIOCRAW, 0) < 0) + { + FatalError("%s: PCCONIOCRAW failed (%s)\n", + "xf86OpenConsole", strerror(errno)); + } + } + return; +} + +void +xf86CloseConsole() +{ + ioctl (xf86Info.consoleFd, PCCONIOCCOOK, 0); + + if (xf86Info.screenFd != xf86Info.consoleFd) + { + close(xf86Info.screenFd); + } + close(xf86Info.consoleFd); + return; +} + +int +xf86ProcessArgument (int argc, char *argv[], int i) +{ + /* + * Keep server from detaching from controlling tty. This is useful + * when debugging (so the server can receive keyboard signals. + */ + if (!strcmp(argv[i], "-keeptty")) + { + KeepTty = TRUE; + return(1); + } + return(0); +} + +void +xf86UseMsg() +{ + ErrorF("-keeptty "); + ErrorF("don't detach controlling tty (for debugging only)\n"); + return; +} -- cgit v1.2.3