From 7ac8228123639c28b6d106505ce513072714cdcd Mon Sep 17 00:00:00 2001 From: Kaleb Keithley Date: Mon, 17 Nov 2003 19:03:48 +0000 Subject: merge XFree86 4.3.0.1 to -CURRENT --- startx.cpp | 179 +++++++++++++++++++++++++++++----- startx.man | 113 +++++++++++++++------- xinit.c | 316 ++++++++++++++++++++++++++++++++++++++++++++++--------------- xinit.man | 16 +++- 4 files changed, 490 insertions(+), 134 deletions(-) diff --git a/startx.cpp b/startx.cpp index 3044ad6..08c0d70 100644 --- a/startx.cpp +++ b/startx.cpp @@ -1,8 +1,8 @@ XCOMM!/bin/sh XCOMM $Xorg: startx.cpp,v 1.3 2000/08/17 19:54:29 cpqbld Exp $ -XCOMM -XCOMM This is just a sample implementation of a slightly less primitive +XCOMM +XCOMM This is just a sample implementation of a slightly less primitive XCOMM interface than xinit. It looks for user .xinitrc and .xserverrc XCOMM files, then system xinitrc and xserverrc files, else lets xinit choose XCOMM its default. The system xinitrc should probably do things like check @@ -10,57 +10,188 @@ XCOMM for .Xresources files and merge them in, startup up a window manager, XCOMM and pop a clock and serveral xterms. XCOMM XCOMM Site administrators are STRONGLY urged to write nicer versions. -XCOMM +XCOMM +XCOMM $XFree86: xc/programs/xinit/startx.cpp,v 3.16 2003/01/24 21:30:02 herrb Exp $ + +#ifdef SCO + +XCOMM Check for /usr/bin/X11 and BINDIR in the path, if not add them. +XCOMM This allows startx to be placed in a place like /usr/bin or /usr/local/bin +XCOMM and people may use X without changing their PATH + +XCOMM First our compiled path + +bindir=BINDIR +if expr $PATH : ".*`echo $bindir | sed 's?/?\\/?g'`.*" > /dev/null 2>&1; then + : +else + PATH=$PATH:BINDIR +fi + +XCOMM Now the "SCO" compiled path + +if expr $PATH : '.*\/usr\/bin\/X11.*' > /dev/null 2>&1; then + : +else + PATH=$PATH:/usr/bin/X11 +fi + +XCOMM Set up the XMERGE env var so that dos merge is happy under X + +if [ -f /usr/lib/merge/xmergeset.sh ]; then + . /usr/lib/merge/xmergeset.sh +elif [ -f /usr/lib/merge/console.disp ]; then + XMERGE=`cat /usr/lib/merge/console.disp` + export XMERGE +fi + +scoclientrc=$HOME/.startxrc +#endif userclientrc=$HOME/.xinitrc userserverrc=$HOME/.xserverrc sysclientrc=XINITDIR/xinitrc sysserverrc=XINITDIR/xserverrc +defaultclient=BINDIR/xterm +defaultserver=BINDIR/X +defaultclientargs="" +defaultserverargs="" clientargs="" serverargs="" +#ifdef SCO +if [ -f $scoclientrc ]; then + defaultclientargs=$scoclientrc +else +#endif if [ -f $userclientrc ]; then - clientargs=$userclientrc -else if [ -f $sysclientrc ]; then - clientargs=$sysclientrc + defaultclientargs=$userclientrc +elif [ -f $sysclientrc ]; then + defaultclientargs=$sysclientrc fi +#ifdef SCO fi +#endif if [ -f $userserverrc ]; then - serverargs=$userserverrc -else if [ -f $sysserverrc ]; then - serverargs=$sysserverrc -fi + defaultserverargs=$userserverrc +elif [ -f $sysserverrc ]; then + defaultserverargs=$sysserverrc fi whoseargs="client" -while [ "x$1" != "x" ]; do +while [ x"$1" != x ]; do case "$1" in - /''*|\.*) if [ "$whoseargs" = "client" ]; then - clientargs="$1" - else - serverargs="$1" - fi ;; - --) whoseargs="server" ;; - *) if [ "$whoseargs" = "client" ]; then - clientargs="$clientargs $1" - else - serverargs="$serverargs $1" - fi ;; + # '' required to prevent cpp from treating "/*" as a C comment. + /''*|\./''*) + if [ "$whoseargs" = "client" ]; then + if [ x"$clientargs" = x ]; then + client="$1" + else + clientargs="$clientargs $1" + fi + else + if [ x"$serverargs" = x ]; then + server="$1" + else + serverargs="$serverargs $1" + fi + fi + ;; + --) + whoseargs="server" + ;; + *) + if [ "$whoseargs" = "client" ]; then + clientargs="$clientargs $1" + else + # display must be the FIRST server argument + if [ x"$serverargs" = x ] && \ + expr "$1" : ':[0-9][0-9]*$' > /dev/null 2>&1; then + display="$1" + else + serverargs="$serverargs $1" + fi + fi + ;; esac shift done -xinit $clientargs -- $serverargs +XCOMM process client arguments +if [ x"$client" = x ]; then + # if no client arguments either, use rc file instead + if [ x"$clientargs" = x ]; then + client="$defaultclientargs" + else + client=$defaultclient + fi +fi + +XCOMM process server arguments +if [ x"$server" = x ]; then + # if no server arguments or display either, use rc file instead + if [ x"$serverargs" = x -a x"$display" = x ]; then + server="$defaultserverargs" + else + server=$defaultserver + fi +fi + +if [ x"$XAUTHORITY" = x ]; then + XAUTHORITY=$HOME/.Xauthority + export XAUTHORITY +fi + +removelist= + +#if defined(HAS_COOKIE_MAKER) && defined(MK_COOKIE) +XCOMM set up default Xauth info for this machine +case `uname` in +Linux*) + if [ -z "`hostname --version 2>&1 | grep GNU`" ]; then + hostname=`hostname -f` + else + hostname=`hostname` + fi + ;; +*) + hostname=`hostname` + ;; +esac + +authdisplay=${display:-:0} +mcookie=`MK_COOKIE` +for displayname in $authdisplay $hostname$authdisplay; do + if ! xauth list "$displayname" | grep "$displayname " >/dev/null 2>&1; then + xauth << EOF +add $displayname . $mcookie +EOF + removelist="$displayname $removelist" + fi +done +#endif + +xinit $client $clientargs -- $server $display $serverargs + +if [ x"$removelist" != x ]; then + xauth remove $removelist +fi /* * various machines need special cleaning up */ +#ifdef __linux__ +if command -v deallocvt > /dev/null 2>&1; then + deallocvt +fi +#endif + #ifdef macII Xrepair screenrestore #endif -#ifdef sun +#if defined(sun) && !defined(i386) kbd_mode -a #endif diff --git a/startx.man b/startx.man index 5d36ed8..4b14a05 100644 --- a/startx.man +++ b/startx.man @@ -6,10 +6,10 @@ .\" the above copyright notice appear in all copies and that both that .\" copyright notice and this permission notice appear in supporting .\" documentation. -.\" +.\" .\" The above copyright notice and this permission notice shall be included .\" in all copies or substantial portions of the Software. -.\" +.\" .\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS .\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF .\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. @@ -17,12 +17,15 @@ .\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, .\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR .\" OTHER DEALINGS IN THE SOFTWARE. -.\" +.\" .\" Except as contained in this notice, the name of The Open Group shall .\" not be used in advertising or otherwise to promote the sale, use or .\" other dealings in this Software without prior written authorization .\" from The Open Group. -.TH STARTX 1 "Release 6.4" "X Version 11" +.\" +.\" $XFree86: xc/programs/xinit/startx.man,v 1.8 2001/12/14 20:01:56 dawes Exp $ +.\" +.TH STARTX 1 __xorgversion__ .SH NAME startx \- initialize an X session .SH SYNOPSIS @@ -39,14 +42,35 @@ startx \- initialize an X session .I options \&.\|.\|. ] .SH DESCRIPTION -NOTE: The \fIstartx\fP script supplied with the X11 distribution is a sample -designed more as a base for customization than as a -finished product. Site administrators are urged to customize it for -their site. And to update this manual page when they do! -.PP The \fIstartx\fP script is a front end to \fIxinit\fP that provides a somewhat nicer user interface for running a single session of the X -Window System. It is typically run with no arguments. +Window System. It is often run with no arguments. +.PP +Arguments immediately following the +.I startx +command are used to start a client in the same manner as +.IR xinit (1). +The special argument +.RB '--' +marks the end of client arguments and the beginning of server options. +It may be convenient to specify server options with startx to change on a +per-session basis the +default color depth, the server's notion of the number of dots-per-inch the +display device presents, or take advantage of a different server layout, as +permitted by the +.IR XFree86 (1) +server and specified in the +.IR XF86Config (__filemansuffix__) +file. Some examples of specifying server arguments follow; consult the +manual page for your X server to determine which arguments are legal. +.RS +.PP +startx -- -depth 16 +.PP +startx -- -dpi 100 +.PP +startx -- -layout Multihead +.RE .PP To determine the client to run, .I startx @@ -59,6 +83,8 @@ in the .I xinit library directory. If command line client options are given, they override this +behavior and revert to the +.IR xinit (1) behavior. To determine the server to run, .I startx @@ -71,6 +97,8 @@ in the .I xinit library directory. If command line server options are given, they override this +behavior and revert to the +.IR xinit (1) behavior. Users rarely need to provide a .I .xserverrc file. @@ -78,35 +106,43 @@ See the .IR xinit (1) manual page for more details on the arguments. .PP +The system-wide +.I xinitrc +and +.I xserverrc +files are found in the +.I __xinitdir__ +directory. +.PP The .I .xinitrc is typically a shell script which starts many clients according to the user's preference. When this shell script exits, -.I startx +.I startx kills the server and performs any other session shutdown needed. Most of the clients started by .I .xinitrc should be run in the background. The last client should run in the foreground; when it exits, the session will exit. People often choose -a session manager, window manager, or \fIxterm\fP as the ``magic'' client. +a session manager, window manager, or \fIxterm\fP as the ''magic'' client. .SH EXAMPLE .PP Below is a sample \fI\.xinitrc\fP that starts several applications and -leaves the window manager running as the ``last'' application. Assuming that +leaves the window manager running as the ''last'' application. Assuming that the window manager has been configured properly, the user -then chooses the ``Exit'' menu item to shut down X. +then chooses the ''Exit'' menu item to shut down X. .sp .in +4 .nf -xrdb \-load $HOME/.Xresources -xsetroot \-solid gray & -xbiff \-geometry \-430+5 & -oclock \-geometry 75x75\-0\-0 & -xload \-geometry \-80\-0 & -xterm \-geometry +0+60 \-ls & -xterm \-geometry +0\-100 & -xconsole \-geometry \-0+0 \-fn 5x7 & -exec twm +xrdb \-load $HOME/.Xresources +xsetroot \-solid gray & +xbiff \-geometry \-430+5 & +oclock \-geometry 75x75\-0\-0 & +xload \-geometry \-80\-0 & +xterm \-geometry +0+60 \-ls & +xterm \-geometry +0\-100 & +xconsole \-geometry \-0+0 \-fn 5x7 & +exec twm .fi .in -4 .SH "ENVIRONMENT VARIABLES" @@ -114,8 +150,20 @@ exec twm DISPLAY This variable gets set to the name of the display to which clients should connect. Note that this gets -.I set, +.IR set , not read. +.TP 25 +XAUTHORITY +This variable, if not already defined, gets set to +.IR $(HOME)/.Xauthority . +This is to prevent the X server, if not given the +.I \-auth +argument, from automatically setting up insecure host-based authentication +for the local host. See the +.IR Xserver (1) +and +.IR Xsecurity (__miscmansuffix__) +manual pages for more information on X client/server authentication. .SH FILES .TP 25 .I $(HOME)/.xinitrc @@ -124,17 +172,18 @@ the background. .TP 25 .I $(HOME)/.xserverrc Server to run. The default is -.I X. +.IR X . .TP 25 -.I /lib/X11/xinit/xinitrc +.I __xinitdir__/xinitrc Client to run if the user has no .I .xinitrc -file. refers to the root of the X11 install tree. +file. .TP 25 -.I /lib/X11/xinit/xserverrc -Client to run if the user has no +.I __xinitdir__/xserverrc +Server to run if the user has no .I .xserverrc -file. This is only needed if the server needs special arguments or is -not named. refers to the root of the X11 install tree. +file. .SH "SEE ALSO" -.IR xinit (1) +.IR xinit (1), +.IR Xserver (1), +.IR XFree86 (1) diff --git a/xinit.c b/xinit.c index 30d8c19..ad6cdc1 100644 --- a/xinit.c +++ b/xinit.c @@ -25,24 +25,51 @@ used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from The Open Group. */ +/* $XFree86: xc/programs/xinit/xinit.c,v 3.32 2002/05/31 18:46:13 dawes Exp $ */ #include #include -#include #include #include + +#ifdef X_POSIX_C_SOURCE +#define _POSIX_C_SOURCE X_POSIX_C_SOURCE +#include +#undef _POSIX_C_SOURCE +#else +#if defined(X_NOT_POSIX) || defined(_POSIX_SOURCE) +#include +#else +#define _POSIX_SOURCE #include +#undef _POSIX_SOURCE +#endif +#endif + #ifndef SYSV #include #endif #include #include +#include -#ifndef X_NOT_STDC_ENV -#include -#else -extern char *getenv(); +#if !defined(SIGCHLD) && defined(SIGCLD) +#define SIGCHLD SIGCLD +#endif +#ifdef __UNIXOS2__ +#define INCL_DOSMODULEMGR +#include +#define setpgid(a,b) +#define setuid(a) +#define setgid(a) +#define SHELL "cmd.exe" +#define XINITRC "xinitrc.cmd" +#define XSERVERRC "xservrc.cmd" +char **envsave; /* to circumvent an UNIXOS2 problem */ +#define environ envsave #endif + +#include extern char **environ; char **newenviron = NULL; @@ -64,6 +91,16 @@ char **newenviron = NULL; #define setpgrp setpgid #endif +#ifdef __UNIXOS2__ +#define HAS_EXECVPE +#endif + +#ifdef HAS_EXECVPE +#define Execvpe(path, argv, envp) execvpe(path, argv, envp) +#else +#define Execvpe(path, argv, envp) execvp(path, argv) +#endif + char *bindir = BINDIR; char *server_names[] = { #if defined(ultrix) && defined(mips) @@ -84,19 +121,14 @@ char *server_names[] = { "XmacII Apple monochrome display on Macintosh II", #endif #ifdef XFREE86 - "XF86_SVGA SVGA color display on i386 PC", - "XF86_Mono monochrome display on i386 PC", - "XF86_VGA16 16 color VGA display on i386 PC", - "XF86_S3 S3 color display on i386 PC", - "XF86_8514 IBM 8514/A color display on i386 PC", - "XF86_Mach8 ATI Mach8 color display on i386 PC", - "XF86_Mach32 ATI Mach32 color display on i386 PC", - "XF86_Mach64 ATI Mach64 color display on i386 PC", - "XF86_P9000 Weitek P9000 color display on i386 PC", - "XF86_AGX IIT AGX color display on i386 PC", - "XF86_W32 Tseng ET4000/W32 color display on i386 PC", - "XF86_I128 #9 I128 color display on i386 PC", + "XFree86 XFree86 displays", +#endif +#ifdef __DARWIN__ + "XDarwin Darwin/Mac OS X IOKit displays", + "XDarwinQuartz Mac OS X Quartz displays", + "XDarwinStartup Auto-select between XDarwin and XDarwinQuartz", #endif + NULL}; #ifndef XINITRC @@ -125,7 +157,7 @@ char *displayNum; char *program; Display *xd; /* server connection */ #ifndef SYSV -#if defined(SVR4) || defined(_POSIX_SOURCE) || defined(CSRG_BASED) +#if defined(__CYGWIN__) || defined(SVR4) || defined(_POSIX_SOURCE) || defined(CSRG_BASED) || defined(__UNIXOS2__) || defined(Lynx) int status; #else union wait status; @@ -133,14 +165,21 @@ union wait status; #endif /* SYSV */ int serverpid = -1; int clientpid = -1; - -#ifdef X_NOT_STDC_ENV -extern int errno; +#ifndef X_NOT_POSIX +volatile int gotSignal = 0; #endif +static void Execute ( char **vec, char **envp ); +static Bool waitforserver ( void ); +static Bool processTimeout ( int timeout, char *string ); +static int startServer ( char *server[] ); +static int startClient ( char *client[] ); +static int ignorexio ( Display *dpy ); +static void shutdown ( void ); +static void set_environment ( void ); +static void Fatal(char *msg); +static void Error ( char *fmt, ... ); -static void shutdown(); -static void set_environment(); #ifdef SIGNALRETURNSINT #define SIGVAL int @@ -148,50 +187,74 @@ static void set_environment(); #define SIGVAL void #endif -SIGVAL sigCatch(sig) - int sig; +#ifdef X_NOT_POSIX +/* Can't use Error() in signal handlers */ +#ifndef STDERR_FILENO +#define WRITES(s) write(STDERR_FILENO, (s), strlen(s)) +#else +#define WRITES(s) write(fileno(stderr), (s), strlen(s)) +#endif +#endif + +static SIGVAL +sigCatch(int sig) { +#ifdef X_NOT_POSIX + char buf[1024]; + signal(SIGQUIT, SIG_IGN); signal(SIGINT, SIG_IGN); signal(SIGHUP, SIG_IGN); signal(SIGPIPE, SIG_IGN); - Error("unexpected signal %d\r\n", sig); + snprintf(buf, sizeof buf, "%s: unexpected signal %d\r\n", + program, sig); + WRITES(buf); shutdown(); - exit(1); + _exit(ERR_EXIT); +#else + /* On system with POSIX signals, just interrupt the system call */ + gotSignal = sig; +#endif } -SIGVAL sigAlarm(sig) - int sig; +static SIGVAL +sigAlarm(int sig) { -#if defined(SYSV) || defined(SVR4) || defined(linux) +#if defined(SYSV) || defined(SVR4) || defined(linux) || defined(__UNIXOS2__) signal (sig, sigAlarm); #endif } -SIGVAL -sigUsr1(sig) - int sig; +static SIGVAL +sigUsr1(int sig) { -#if defined(SYSV) || defined(SVR4) || defined(linux) +#if defined(SYSV) || defined(SVR4) || defined(linux) || defined(__UNIXOS2__) signal (sig, sigUsr1); #endif } -static void Execute (vec) - char **vec; /* has room from up above */ +static void +Execute(char **vec, /* has room from up above */ + char **envp) { - execvp (vec[0], vec); + Execvpe (vec[0], vec, envp); +#ifndef __UNIXOS2__ if (access (vec[0], R_OK) == 0) { vec--; /* back it up to stuff shell in */ vec[0] = SHELL; - execvp (vec[0], vec); + Execvpe (vec[0], vec, envp); } +#endif return; } -main(argc, argv) -int argc; -register char **argv; +#ifndef __UNIXOS2__ +int +main(int argc, char *argv[]) +#else +int +main(int argc, char *argv[], char *envp[]) +#endif { register char **sptr = server; register char **cptr = client; @@ -200,15 +263,43 @@ register char **argv; int client_given = 0, server_given = 0; int client_args_given = 0, server_args_given = 0; int start_of_client_args, start_of_server_args; +#ifndef X_NOT_POSIX + struct sigaction sa; +#endif +#ifdef __UNIXOS2__ + envsave = envp; /* circumvent an EMX problem */ + + /* Check whether the system will run at all */ + if (_emx_rev < 50) { + APIRET rc; + HMODULE hmod; + char name[CCHMAXPATH]; + char fail[9]; + fputs ("This program requires emx.dll revision 50 (0.9c) " + "or later.\n", stderr); + rc = DosLoadModule (fail, sizeof (fail), "emx", &hmod); + if (rc == 0) { + rc = DosQueryModuleName (hmod, sizeof (name), name); + if (rc == 0) + fprintf (stderr, "Please delete or update `%s'.\n", name); + DosFreeModule (hmod); + } + exit (2); + } +#endif program = *argv++; argc--; - /* * copy the client args. */ if (argc == 0 || +#ifndef __UNIXOS2__ (**argv != '/' && **argv != '.')) { +#else + (**argv != '/' && **argv != '\\' && **argv != '.' && + !(isalpha(**argv) && (*argv)[1]==':'))) { +#endif for (ptr = default_client; *ptr; ) *cptr++ = *ptr++; #ifdef sun @@ -239,8 +330,19 @@ register char **argv; * Copy the server args. */ if (argc == 0 || +#ifndef __UNIXOS2__ (**argv != '/' && **argv != '.')) { *sptr++ = default_server; +#else + (**argv != '/' && **argv != '\\' && **argv != '.' && + !(isalpha(**argv) && (*argv)[1]==':'))) { + *sptr = getenv("XSERVER"); + if (!*sptr) { + Error("No XSERVER environment variable set"); + exit(1); + } + *sptr++; +#endif } else { server_given = 1; *sptr++ = *argv++; @@ -321,16 +423,36 @@ register char **argv; /* * Start the server and client. */ +#ifdef SIGCHLD + signal(SIGCHLD, SIG_DFL); /* Insurance */ +#endif +#ifdef X_NOT_POSIX signal(SIGQUIT, sigCatch); signal(SIGINT, sigCatch); signal(SIGHUP, sigCatch); signal(SIGPIPE, sigCatch); +#else + /* Let those signal interrupt the wait() call in the main loop */ + memset(&sa, 0, sizeof sa); + sa.sa_handler = sigCatch; + sigemptyset(&sa.sa_mask); + sa.sa_flags = 0; /* do not set SA_RESTART */ + + sigaction(SIGQUIT, &sa, NULL); + sigaction(SIGINT, &sa, NULL); + sigaction(SIGHUP, &sa, NULL); + sigaction(SIGPIPE, &sa, NULL); +#endif signal(SIGALRM, sigAlarm); signal(SIGUSR1, sigUsr1); if (startServer(server) > 0 && startClient(client) > 0) { pid = -1; - while (pid != clientpid && pid != serverpid) + while (pid != clientpid && pid != serverpid +#ifndef X_NOT_POSIX + && gotSignal == 0 +#endif + ) pid = wait(NULL); } signal(SIGQUIT, SIG_IGN); @@ -339,7 +461,12 @@ register char **argv; signal(SIGPIPE, SIG_IGN); shutdown(); - +#ifndef X_NOT_POSIX + if (gotSignal != 0) { + Error("unexpected signal %d.\n", gotSignal); + exit(ERR_EXIT); + } +#endif if (serverpid < 0 ) Fatal("Server error.\n"); if (clientpid < 0) @@ -351,8 +478,8 @@ register char **argv; /* * waitforserver - wait for X server to start up */ - -waitforserver() +static Bool +waitforserver(void) { int ncycles = 120; /* # of cycles to wait */ int cycles; /* Wait cycle count */ @@ -376,21 +503,20 @@ waitforserver() /* * return TRUE if we timeout waiting for pid to exit, FALSE otherwise. */ -processTimeout(timeout, string) - int timeout; - char *string; +static Bool +processTimeout(int timeout, char *string) { int i = 0, pidfound = -1; static char *laststring; for (;;) { -#ifdef SYSV +#if defined(SYSV) || defined(__UNIXOS2__) alarm(1); if ((pidfound = wait(NULL)) == serverpid) break; alarm(0); #else /* SYSV */ -#if defined(SVR4) || defined(_POSIX_SOURCE) +#if defined(SVR4) || defined(_POSIX_SOURCE) || defined(Lynx) if ((pidfound = waitpid(serverpid, &status, WNOHANG)) == serverpid) break; #else @@ -415,12 +541,33 @@ processTimeout(timeout, string) return( serverpid != pidfound ); } -startServer(server) - char *server[]; +static int +startServer(char *server[]) { - serverpid = vfork(); +#if !defined(X_NOT_POSIX) + sigset_t mask, old; +#else + int old; +#endif + +#if !defined(X_NOT_POSIX) + sigemptyset(&mask); + sigaddset(&mask, SIGUSR1); + sigprocmask(SIG_BLOCK, &mask, &old); +#else + old = sigblock (sigmask (SIGUSR1)); +#endif + serverpid = fork(); + switch(serverpid) { case 0: + /* Unblock */ +#ifndef X_NOT_POSIX + sigprocmask(SIG_SETMASK, &old, NULL); +#else + sigsetmask (old); +#endif + /* * don't hang on read/write to control tty */ @@ -440,9 +587,10 @@ startServer(server) * prevent server from getting sighup from vhangup() * if client is xterm -L */ +#ifndef __UNIXOS2__ setpgrp(0,getpid()); - - Execute (server); +#endif + Execute (server, environ); Error ("no server \"%s\" in PATH\n", server[0]); { char **cpp; @@ -487,8 +635,16 @@ startServer(server) * you can easily adjust this value. */ alarm (15); - pause (); + +#ifndef X_NOT_POSIX + sigsuspend(&old); + alarm (0); + sigprocmask(SIG_SETMASK, &old, NULL); +#else + sigpause (old); alarm (0); + sigsetmask (old); +#endif if (waitforserver() == 0) { Error("unable to connect to X server\r\n"); @@ -501,41 +657,47 @@ startServer(server) return(serverpid); } -startClient(client) - char *client[]; +static int +startClient(char *client[]) { if ((clientpid = vfork()) == 0) { setuid(getuid()); setpgrp(0, getpid()); environ = newenviron; - Execute (client); +#ifdef __UNIXOS2__ +#undef environ + environ = newenviron; + client[0] = (char*)__XOS2RedirRoot(client[0]); +#endif + Execute (client,newenviron); Error ("no program named \"%s\" in PATH\r\n", client[0]); fprintf (stderr, "\nSpecify a program on the command line or make sure that %s\r\n", bindir); fprintf (stderr, "is in your path.\r\n"); fprintf (stderr, "\n"); - exit (ERR_EXIT); + _exit (ERR_EXIT); } return (clientpid); } -#if !defined(X_NOT_POSIX) || defined(SYSV) +#if !defined(X_NOT_POSIX) || defined(SYSV) || defined(__UNIXOS2__) #define killpg(pgrp, sig) kill(-(pgrp), sig) #endif static jmp_buf close_env; -static int ignorexio (dpy) - Display *dpy; +static int +ignorexio(Display *dpy) { fprintf (stderr, "%s: connection to X server lost.\r\n", program); longjmp (close_env, 1); /*NOTREACHED*/ + return 0; } -static -void shutdown() +static void +shutdown(void) { /* have kept display opened, so close it now */ if (clientpid > 0) { @@ -588,7 +750,8 @@ void shutdown() * make a new copy of environment that has room for DISPLAY */ -static void set_environment () +static void +set_environment(void) { int nenvvars; char **newPtr, **oldPtr; @@ -622,17 +785,22 @@ static void set_environment () return; } -Fatal(fmt, x0,x1,x2,x3,x4,x5,x6,x7,x8,x9) - char *fmt; +static void +Fatal(char *msg) { - Error(fmt, x0,x1,x2,x3,x4,x5,x6,x7,x8,x9); + Error(msg); exit(ERR_EXIT); } -Error(fmt, x0,x1,x2,x3,x4,x5,x6,x7,x8,x9) - char *fmt; +static void +Error(char *fmt, ...) { + va_list ap; + + va_start(ap, fmt); fprintf(stderr, "%s: ", program); - fprintf (stderr, "%s (errno %d): ", strerror(errno), errno); - fprintf(stderr, fmt, x0,x1,x2,x3,x4,x5,x6,x7,x8,x9); + if (errno > 0) + fprintf (stderr, "%s (errno %d): ", strerror(errno), errno); + vfprintf(stderr, fmt, ap); + va_end(ap); } diff --git a/xinit.man b/xinit.man index 23e2315..ecf7353 100644 --- a/xinit.man +++ b/xinit.man @@ -22,7 +22,10 @@ .\" not be used in advertising or otherwise to promote the sale, use or .\" other dealings in this Software without prior written authorization .\" from The Open Group. -.TH XINIT 1 "Release 6.4" "X Version 11" +.\" +.\" $XFree86: xc/programs/xinit/xinit.man,v 3.10 2001/12/14 20:01:56 dawes Exp $ +.\" +.TH XINIT 1 __xorgversion__ .SH NAME xinit \- X Window System initializer .SH SYNOPSIS @@ -69,6 +72,11 @@ server. The site administrator should, therefore, make a link to the appropriate type of server on the machine, or create a shell script that runs \fIxinit\fP with the appropriate server. .PP +Note, when using a \fI.xserverrc\fP script be sure to ``exec'' the real X server. +Failing to do this can make the X server slow to start and exit. For example: +.sp + exec Xdisplaytype +.PP An important point is that programs which are run by \fI\.xinitrc\fP should be run in the background if they do not exit right away, so that they don't prevent other programs from @@ -143,7 +151,7 @@ a default \fI\.xinitrc\fP that references a site-wide startup file: .sp .in +8 .nf -#!/bin/sh +\&#!/bin/sh \&. /usr/local/lib/site.xinitrc .fi .in -8 @@ -155,7 +163,7 @@ novice users: .sp .in +8 .nf -#!/bin/sh +\&#!/bin/sh xinit /usr/local/lib/site.xinitrc \-\^\- /usr/X11R6/bin/X bc .fi .in -8 @@ -184,7 +192,7 @@ default server script .I X server to run if \fI.xserverrc\fP does not exist .SH "SEE ALSO" -.IR X (1), +.IR X (__miscmansuffix__), .IR startx (1), .IR Xserver (1), .IR xterm (1) -- cgit v1.2.3