[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

xinit: Changes to 'upstream-unstable'



 .gitignore                                          |   77 +
 INSTALL                                             |  236 ---
 Makefile.am                                         |   25 
 configure.ac                                        |   67 -
 cpprules.in                                         |    8 
 org.x.startx.plist.cpp                              |    4 
 privileged_startx/.gitignore                        |    9 
 privileged_startx/Makefile.am                       |    7 
 privileged_startx/client.c                          |    4 
 privileged_startx/org.x.privileged_startx.plist.cpp |    4 
 privileged_startx/privileged_startx_types.h         |    6 
 privileged_startx/server.c                          |    8 
 startx.cmd                                          |   81 -
 startx.cpp                                          |   34 
 startx.man                                          |   44 
 xinit.c                                             | 1226 ++++++++------------
 xinit.def                                           |    4 
 xinit.man                                           |   79 -
 xinitrc.cmd                                         |   62 -
 xinitrc.cpp                                         |    5 
 20 files changed, 748 insertions(+), 1242 deletions(-)

New commits:
commit cc92823c61f9f4d31a25d107017198d1e16d4fcf
Author: Alan Coopersmith <alan.coopersmith@oracle.com>
Date:   Sat Oct 30 16:44:22 2010 -0700

    xinit 1.3.0
    
    Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>

diff --git a/configure.ac b/configure.ac
index 974ea99..7650249 100644
--- a/configure.ac
+++ b/configure.ac
@@ -21,7 +21,8 @@ dnl
 dnl Process this file with autoconf to create configure.
 
 AC_PREREQ([2.60])
-AC_INIT(xinit,[1.2.1], [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg],xinit)
+AC_INIT([xinit], [1.3.0],
+        [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], [xinit])
 AM_INIT_AUTOMAKE([foreign dist-bzip2])
 AM_MAINTAINER_MODE
 

commit b5ff96271ebf30422f0a4af487ba9b35ce9c2e80
Author: Alan Coopersmith <alan.coopersmith@oracle.com>
Date:   Thu Sep 23 20:26:42 2010 -0700

    config: Remove unnecessary calls from configure.ac
    
    AC_PROG_CC, AC_PROG_SED, & AC_PROG_INSTALL are provided by
    XORG_DEFAULT_OPTIONS 1.8
    
    Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>

diff --git a/configure.ac b/configure.ac
index 0127329..974ea99 100644
--- a/configure.ac
+++ b/configure.ac
@@ -25,19 +25,15 @@ AC_INIT(xinit,[1.2.1], [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg]
 AM_INIT_AUTOMAKE([foreign dist-bzip2])
 AM_MAINTAINER_MODE
 
-# Require xorg-macros: XORG_DEFAULT_OPTIONS
+# Require X.Org macros 1.8 or later for AC_PROG_SED in XORG_DEFAULT_OPTIONS
 m4_ifndef([XORG_MACROS_VERSION],
-          [m4_fatal([must install xorg-macros 1.3 or later before running autoconf/autogen])])
-XORG_MACROS_VERSION(1.3)
+          [m4_fatal([must install xorg-macros 1.8 or later before running autoconf/autogen])])
+XORG_MACROS_VERSION(1.8)
 XORG_DEFAULT_OPTIONS
 
 AM_CONFIG_HEADER(config.h)
 
-AC_PROG_CC
-AM_PROG_CC_C_O
 XORG_PROG_RAWCPP
-AC_PROG_INSTALL
-AC_PATH_PROG(SED,sed)
 AC_CANONICAL_HOST
 
 m4_ifdef([AS_HELP_STRING], , [m4_define([AS_HELP_STRING], m4_defn([AC_HELP_STRING]))])

commit 4afe755b28f48390b16d16434cd14a756ef464ce
Author: Gaetan Nadon <memsize@videotron.ca>
Date:   Tue Jul 20 18:45:18 2010 -0400

    config: update AC_PREREQ statement to 2.60
    
    Unrelated to the previous patches, the new value simply reflects
    the reality that the minimum level for autoconf to configure
    all x.org modules is 2.60 dated June 2006.
    
    ftp://ftp.gnu.org/gnu/autoconf/autoconf-2.60.tar.gz
    
    Signed-off-by: Gaetan Nadon <memsize@videotron.ca>

diff --git a/configure.ac b/configure.ac
index c4f4c84..0127329 100644
--- a/configure.ac
+++ b/configure.ac
@@ -20,7 +20,7 @@ dnl  PERFORMANCE OF THIS SOFTWARE.
 dnl
 dnl Process this file with autoconf to create configure.
 
-AC_PREREQ([2.57])
+AC_PREREQ([2.60])
 AC_INIT(xinit,[1.2.1], [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg],xinit)
 AM_INIT_AUTOMAKE([foreign dist-bzip2])
 AM_MAINTAINER_MODE

commit d15d988eaf63d4f840d09ba12caade6bea5f7618
Author: Jeremy Huddleston <jeremyhu@apple.com>
Date:   Mon Jul 12 16:55:03 2010 -0700

    launchd: Explicitly search /sbin
    
    Previously, launchd wasn't found if /sbin wasn't in the user's PATH.
    https://bugs.freedesktop.org/show_bug.cgi?id=29028
    
    Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>

diff --git a/configure.ac b/configure.ac
index 8930b39..c4f4c84 100644
--- a/configure.ac
+++ b/configure.ac
@@ -113,7 +113,7 @@ AC_ARG_WITH(launchd-id-prefix,  AS_HELP_STRING([--with-launchd-id-prefix=PATH],
 
 if test "x$LAUNCHD" = "xauto"; then
 	unset LAUNCHD
-	AC_CHECK_PROG(LAUNCHD, [launchd], [yes], [no])
+	AC_CHECK_PROG(LAUNCHD, [launchd], [yes], [no], [$PATH$PATH_SEPARATOR/sbin])
 fi
 
 TIGER_LAUNCHD=no

commit 908273df8c0a7a13ff20e4ed4b7b470521f12ce2
Author: David Shao <davshao@gmail.com>
Date:   Fri May 21 12:44:53 2010 -0700

    DragonFly BSD: includes for PRIO_PROCESS and setpriority() in xinit.c
    
    Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>

diff --git a/xinit.c b/xinit.c
index 313806e..0d31637 100644
--- a/xinit.c
+++ b/xinit.c
@@ -48,6 +48,12 @@ in this Software without prior written authorization from The Open Group.
 #endif
 #endif
 
+/* For PRIO_PROCESS and setpriority() */
+#ifdef __DragonFly__
+#include <sys/time.h>
+#include <sys/resource.h>
+#endif /* __DragonFly__ */
+
 #include <stdlib.h>
 
 #ifndef SHELL

commit 8464a8ab360b72f6817b19ce99b12f0793fbee74
Author: Jeremy Huddleston <jeremyhu@apple.com>
Date:   Mon May 3 00:25:30 2010 -0700

    darwin: Make __APPLE__ path in startx POSIX compliant
    
    http://xquartz.macosforge.org/trac/ticket/399
    
    Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>

diff --git a/startx.cpp b/startx.cpp
index 48d40aa..f055ad9 100644
--- a/startx.cpp
+++ b/startx.cpp
@@ -87,15 +87,15 @@ if [ "x$X11_PREFS_DOMAIN" = x ] ; then
 fi
 
 XCOMM Initialize defaults (this will cut down on "safe" error messages)
-if ! defaults read $X11_PREFS_DOMAIN cache_fonts >& /dev/null ; then
+if ! defaults read $X11_PREFS_DOMAIN cache_fonts > /dev/null 2>&1 ; then
     defaults write $X11_PREFS_DOMAIN cache_fonts -bool true
 fi
 
-if ! defaults read $X11_PREFS_DOMAIN no_auth >& /dev/null ; then
+if ! defaults read $X11_PREFS_DOMAIN no_auth > /dev/null 2>&1 ; then
     defaults write $X11_PREFS_DOMAIN no_auth -bool false
 fi
 
-if ! defaults read $X11_PREFS_DOMAIN nolisten_tcp >& /dev/null ; then
+if ! defaults read $X11_PREFS_DOMAIN nolisten_tcp > /dev/null 2>&1 ; then
     defaults write $X11_PREFS_DOMAIN nolisten_tcp -bool true
 fi
 
@@ -126,14 +126,17 @@ if [ x`defaults read $X11_PREFS_DOMAIN nolisten_tcp` = x1 ] ; then
     defaultserverargs="$defaultserverargs -nolisten tcp"
 fi
 
-if defaults read $X11_PREFS_DOMAIN dpi >& /dev/null ; then
+if defaults read $X11_PREFS_DOMAIN dpi > /dev/null 2>&1 ; then
     defaultserverargs="$defaultserverargs -dpi `defaults read $X11_PREFS_DOMAIN dpi`"
 fi
 
-for ((d=0; ; d++)) ; do
-    [[ -e /tmp/.X$d-lock ]] || break
+d=0
+while true ; do
+    [ -e /tmp/.X$d-lock ] || break
+    d=$(($d + 1))
 done
 defaultdisplay=":$d"
+unset d
 
 #else
 enable_xauth=1
@@ -278,7 +281,8 @@ if [ x"$enable_xauth" = x1 ] ; then
 add :$dummy . $mcookie
 EOF
 #if defined(__APPLE__) || defined(__CYGWIN__)
-    serverargs=${serverargs}" -auth '"${xserverauthfile//\'/\'\\\'\'}"'"
+    xserverauthfilequoted=$(echo ${xserverauthfile} | sed "s/'/'\\\\''/g")
+    serverargs=${serverargs}" -auth '"${xserverauthfilequoted}"'"
 #else
     serverargs=${serverargs}" -auth "${xserverauthfile}
 #endif

commit e4548fe62d58d7cb891dc142c400c22031d471fb
Author: Mikhail Gusarov <dottedmag@dottedmag.net>
Date:   Sun Apr 25 03:21:43 2010 +0700

    Remove OS/2 leftovers
    
    Signed-off-by: Mikhail Gusarov <dottedmag@dottedmag.net>
    Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>

diff --git a/Makefile.am b/Makefile.am
index 28e7c78..2b8a4eb 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -76,7 +76,7 @@ MAINTAINERCLEANFILES = ChangeLog INSTALL
 CLEANFILES = xinitrc startx $(appman_DATA) $(launchagents_DATA)
 
 EXTRA_DIST = xinitrc.cpp startx.cpp org.x.startx.plist.cpp $(appman_PRE)	\
-		startx.cmd xinitrc.cmd xinit.def autogen.sh
+		autogen.sh
 
 .PHONY: ChangeLog INSTALL
 
diff --git a/startx.cmd b/startx.cmd
deleted file mode 100644
index 950ab9d..0000000
--- a/startx.cmd
+++ /dev/null
@@ -1,80 +0,0 @@
-/* OS/2 REXX */
-/*
- * This is just a sample implementation of a slightly less primitive 
- * interface than xinit.  It looks for user xinitrc.cmd and xservrc.cmd
- * files, then system xinitrc.cmd and xservrc.cmd files, else lets xinit choose
- * its default.  The system xinitrc should probably do things like check
- * for Xresources files and merge them in, startup up a window manager,
- * and pop a clock and serveral xterms.
- *
- * Site administrators are STRONGLY urged to write nicer versions.
- */
-'@echo off'
-ADDRESS CMD
-env = 'OS2ENVIRONMENT'
-x11root = VALUE('X11ROOT',,env)
-IF x11root = '' THEN DO
-	SAY "The environment variable X11ROOT is not set. X/OS2 won't run without it."
-	EXIT
-END
-
-home = VALUE('HOME',,env)
-IF home = '' THEN home = x11root
-os_shell = VALUE('X11SHELL',,env)
-IF os_shell = '' THEN os_shell = VALUE('SHELL',,env)
-IF os_shell = '' THEN os_shell = VALUE('OS2_SHELL',,env)
-IF os_shell = '' THEN DO
-	SAY "There is no command interpreter in OS2_SHELL ???"
-	EXIT
-END
-
-userclientrc = home'\xinitrc.cmd'
-userserverrc = home'\xservrc.cmd'
-sysclientrc  = x11root'\usr\X11R6\lib\X11\xinit\xinitrc.cmd'
-sysserverrc  = x11root'\usr\X11R6\lib\X11\xinit\xservrc.cmd'
-clientargs   = ''
-serverargs   = ''
-
-IF exists(userclientrc) THEN
-	clientargs = userclientrc
-ELSE 
-IF exists(sysclientrc) THEN
-	clientargs = sysclientrc
-
-IF exists(userserverrc) THEN
-	serverargs = userserverrc
-ELSE 
-IF exists(sysserverrc) THEN
-	serverargs = sysserverrc
-
-whoseargs = "client"
-PARSE ARG all
-
-DO i=1 TO WORDS(all)
-	cur = WORD(all,i)
-	IF \(FILESPEC('DRIVE',cur) = '') THEN DO
-		IF whoseargs = "client" THEN
-			clientargs = cur
-		ELSE
-			serverargs = cur
-	END
-	ELSE
-	IF cur = "--" THEN 
-		whoseargs = "server"
-	ELSE 
-	IF whoseargs = "client" THEN
-		clientargs = clientargs' 'cur
-	ELSE
-		serverargs = serverargs' 'cur
-END
-
-xinit = x11root'\usr\X11R6\bin\xinit'
-xinit os_shell' /c 'clientargs' -- 'serverargs
-
-RETURN
-
-exists:
-	IF STREAM(arg(1), 'C', 'QUERY EXISTS') = '' THEN
-		RETURN 0
-	ELSE
-		RETURN 1
diff --git a/xinit.def b/xinit.def
deleted file mode 100644
index 92c4176..0000000
--- a/xinit.def
+++ /dev/null
@@ -1,4 +0,0 @@
-NAME xinit NOTWINDOWCOMPAT
-DESCRIPTION "@#XFREE86:4.4.0#@ $XFree86: xc/programs/xinit/xinit.def,v 3.2 2002/05/31 18:46:13 dawes Exp $"
-PROTMODE
-EXETYPE OS2
diff --git a/xinitrc.cmd b/xinitrc.cmd
deleted file mode 100644
index 623a159..0000000
--- a/xinitrc.cmd
+++ /dev/null
@@ -1,61 +0,0 @@
-/* OS/2 REXX */
-'@echo off'
-env = 'OS2ENVIRONMENT'
-x11root = VALUE('X11ROOT',,env)
-IF x11root = '' THEN DO
-	SAY "The environment variable X11ROOT is not set. X/OS2 won't run without it."
-	EXIT
-END
-home = VALUE('HOME',,env)
-IF home = '' THEN home = x11root
-
-userresources = home'\.Xresources'
-usermodmap    = home'\.Xmodmap'
-sysresources  = x11root'\usr\X11R6\lib\X11\xinit\.Xresources'
-sysmodmap     = x11root'\usr\X11R6\lib\X11\xinit\.Xmodmap'
-xbitmapdir    = x11root'\usr\X11R6\include\X11\bitmaps'
-manpath       = VALUE('MANPATH',,env)
-
-/* merge in defaults */
-IF exists(sysresources) THEN
-	'xrdb -merge 'sysresources
-
-IF exists(sysmodmap) THEN
-	'xmodmap 'sysmodmap
-
-IF exists(userresources) THEN
-	'xrdb -merge 'userresources
-
-IF exists(usermodmap) THEN
-	'xmodmap 'usermodmap
-
-/* start some nice :-) test programs */
-'xsetroot -bitmap 'xbitmapdir'\xos2'
-/* also try out the following ones: 
- * 'xsetroot -bitmap 'xbitmapdir'\xfree1'
- * 'xsetroot -bitmap 'xbitmapdir'\xfree2'
- */
-
-/****** WARNING! *********
- * Below some programs are started minimized, some are started detached.
- * In general, those that spawn other shells are minimized, others may be
- * detached. You might be tempted to run the xterm's as well as detached.
- * This works, but leaves you with an independent xterm/cmd pair, when the 
- * server shuts down, which you can only see in watchcat, not the process list.
- * If you start and stop x11 multiple times, this will let you run out of
- * PTYs, and will lead to a large number of background sessions.
- */
-'detach xclock -update 1 -geometry 100x100-1+1'
-'start/min/n "Login Xterm" xterm -sb -geometry 80x25+0+0 -name login'
-IF manpath \= '' THEN
-	'detach xman -geometry 100x100-105+1'
-/* 'startx/min/n "Xterm 1" xterm -sb -geometry 80x50+494+51' */
-/* 'startx/min/n "Xterm 2" xterm -sb -geometry 80x20+494-0' */
-'twm'
-
-EXIT
-
-exists:
-'DIR "'arg(1)'" >nul 2>&1'
-if rc = 0 THEN RETURN 1
-RETURN 0

commit c82295911409c611c097ef2e1269a78d54314304
Author: Jeremy Huddleston <jeremyhu@apple.com>
Date:   Thu Apr 15 11:40:33 2010 -0700

    Enable support for an xinitrc.d directory
    
    This was already done on darwin and Gentoo.  Now others can benefit.
    
    Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
    Reviewed-by: Dan Nicholson <dbn.lists@gmail.com>
    Reviewed-by: Rémi Cardona <remi@gentoo.org>
    Reviewed-by: James Cloos <cloos@jhcloos.com>

diff --git a/xinitrc.cpp b/xinitrc.cpp
index 379b1f3..049a8e4 100644
--- a/xinitrc.cpp
+++ b/xinitrc.cpp
@@ -84,8 +84,6 @@ fi
 XCOMM This is the fallback case if nothing else is executed above
 #endif /* !defined(__SCO__)  && !defined(__UNIXWARE__) */
 
-#ifdef __APPLE__
-
 if [ -d XINITDIR/xinitrc.d ] ; then
 	for f in XINITDIR/xinitrc.dXSLASHGLOB.sh ; do
 		[ -x "$f" ] && . "$f"
@@ -93,8 +91,6 @@ if [ -d XINITDIR/xinitrc.d ] ; then
 	unset f
 fi
 
-#endif
-
 TWM &
 XCLOCK -geometry 50x50-1+1 &
 XTERM -geometry 80x50+494+51 &

commit 7f9d31e6342ffe5f2903fb2f4e5d3a1e4e5ed1df
Author: Mikhail Gusarov <dottedmag@dottedmag.net>
Date:   Wed Apr 14 03:03:29 2010 +0700

    Rationalize errors output
    
    Implement Errorx/Fatalx in addition to existing Error/Fatal, replace
    all fprintf(stderr)/exit with Fatal, all fprintf(stderr) with Error.
    
    Additionally harmonize capitalization and punctuation of error messages.
    
    Signed-off-by: Mikhail Gusarov <dottedmag@dottedmag.net>
    Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>

diff --git a/xinit.c b/xinit.c
index cb622a2..313806e 100644
--- a/xinit.c
+++ b/xinit.c
@@ -109,8 +109,11 @@ 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 Fatal(const char *fmt, ...);
+static void Error(const char *fmt, ...);
+static void Fatalx(const char *fmt, ...);
+static void Errorx(const char *fmt, ...);
 
 static void
 sigCatch(int sig)
@@ -221,9 +224,7 @@ main(int argc, char *argv[])
                 client += start_of_client_args - 1;
                 client[0] = xinitrcbuf;
             } else if (required) {
-                fprintf(stderr,
-                        "%s:  warning, no client init file \"%s\"\n",
-                        program, xinitrcbuf);
+                Error("warning, no client init file \"%s\"", xinitrcbuf);
             }
         }
     }
@@ -249,9 +250,7 @@ main(int argc, char *argv[])
                 server += start_of_server_args - 1;
                 server[0] = xserverrcbuf;
             } else if (required) {
-                fprintf(stderr,
-                        "%s:  warning, no server init file \"%s\"\n",
-                        program, xserverrcbuf);
+                Error("warning, no server init file \"%s\"", xserverrcbuf);
             }
         }
     }
@@ -311,14 +310,14 @@ main(int argc, char *argv[])
     shutdown();
 
     if (gotSignal != 0) {
-        Error("unexpected signal %d.\n", gotSignal);
+        Errorx("unexpected signal %d", gotSignal);
         exit(EXIT_FAILURE);
     }
 
     if (serverpid < 0)
-        Fatal("Server error.\n");
+        Fatalx("server error");
     if (clientpid < 0)
-        Fatal("Client error.\n");
+        Fatalx("client error");
     exit(EXIT_SUCCESS);
 }
 
@@ -352,7 +351,8 @@ waitforserver(void)
         }
     }
 
-    fprintf(stderr, "giving up.\r\n");
+    Errorx("giving up");
+
     return(FALSE);
 }
 
@@ -389,6 +389,7 @@ static int
 startServer(char *server[])
 {
     sigset_t mask, old;
+    const char * const *cpp;
 
     sigemptyset(&mask);
     sigaddset(&mask, SIGUSR1);
@@ -418,23 +419,16 @@ startServer(char *server[])
          */
         setpgid(0,getpid());
         Execute(server);
-        Error("no server \"%s\" in PATH\n", server[0]);
-        {
-            const char * const *cpp;
-
-            fprintf(stderr,
-                    "\nUse the -- option, or make sure that %s is in your path and\n",
-                    bindir);
-            fprintf(stderr,
-                    "that \"%s\" is a program or a link to the right type of server\n",
-                    server[0]);
-            fprintf(stderr,
-                    "for your display.  Possible server names include:\n\n");
-            for (cpp = server_names; *cpp; cpp++) {
-                fprintf(stderr, "    %s\n", *cpp);
-            }
-            fprintf(stderr, "\n");
-        }
+
+        Error("unable to run server \"%s\"", server[0]);
+
+        fprintf(stderr, "Use the -- option, or make sure that %s is in your path and\n", bindir);
+        fprintf(stderr, "that \"%s\" is a program or a link to the right type of server\n", server[0]);
+        fprintf(stderr, "for your display.  Possible server names include:\n\n");
+        for (cpp = server_names; *cpp; cpp++)
+            fprintf(stderr, "    %s\n", *cpp);
+        fprintf(stderr, "\n");
+
         exit(EXIT_FAILURE);
 
         break;
@@ -466,7 +460,7 @@ startServer(char *server[])
         sigprocmask(SIG_SETMASK, &old, NULL);
 
         if (waitforserver() == 0) {
-            Error("unable to connect to X server\r\n");
+            Error("unable to connect to X server");
             shutdown();
             serverpid = -1;
         }
@@ -494,23 +488,17 @@ setWindowPath(void)
     size_t len;
     prop = XInternAtom(xd, "XFree86_VT", False);
     if (prop == None) {
-#ifdef DEBUG
-        fprintf(stderr, "no XFree86_VT atom\n");
-#endif
+        Errorx("Unable to intern XFree86_VT atom");
         return;
     }
     if (XGetWindowProperty(xd, DefaultRootWindow(xd), prop, 0, 1,
         False, AnyPropertyType, &actualtype, &actualformat,
         &nitems, &bytes_after, &buf)) {
-#ifdef DEBUG
-        fprintf(stderr, "no XFree86_VT property\n");
-#endif
+        Errorx("No XFree86_VT property detected on X server, WINDOWPATH won't be set");
         return;
     }
     if (nitems != 1) {
-#ifdef DEBUG
-        fprintf(stderr, "%lu items in XFree86_VT property!\n", nitems);
-#endif
+        Errorx("XFree86_VT property unexpectedly has %lu items instead of 1", nitems);
         XFree(buf);
         return;
     }
@@ -529,17 +517,13 @@ setWindowPath(void)
             num = (*(uint32_t *)(void *)buf);
             break;
         default:
-#ifdef DEBUG
-            fprintf(stderr, "format %d in XFree86_VT property!\n", actualformat);
-#endif
+            Errorx("XFree86_VT property has unexpected format %d", actualformat);
             XFree(buf);
             return;
         }
         break;
     default:
-#ifdef DEBUG
-        fprintf(stderr, "type %lx in XFree86_VT property!\n", actualtype);
-#endif
+        Errorx("XFree86_VT property has unexpected type %lx", actualtype);
         XFree(buf);
         return;
     }
@@ -561,7 +545,8 @@ setWindowPath(void)
                  windowpath, nums);
     }
     if (setenv("WINDOWPATH", newwindowpath, TRUE) == -1)
-        fprintf(stderr, "%s:  unable to set WINDOWPATH\n", program);
+        Error("unable to set WINDOWPATH");
+
 
     free(newwindowpath);
 }
@@ -575,17 +560,16 @@ startClient(char *client[])
         setWindowPath();
 
         if (setuid(getuid()) == -1) {
-            Error("cannot change uid: %s\n", strerror(errno));
+            Error("cannot change uid");
             _exit(EXIT_FAILURE);
         }
         setpgid(0, getpid());
         Execute(client);
-        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");
+        Error("Unable to run program \"%s\"", client[0]);
+
+        fprintf(stderr, "Specify a program on the command line or make sure that %s\n", bindir);
+        fprintf(stderr, "is in your path.\n\n");
+
         _exit(EXIT_FAILURE);
     } else {
         return clientpid;
@@ -597,7 +581,7 @@ static jmp_buf close_env;
 static int
 ignorexio(Display *dpy)
 {
-    fprintf(stderr, "%s:  connection to X server lost.\r\n", program);
+    Errorx("connection to X server lost");
     longjmp(close_env, 1);
     /*NOTREACHED*/
     return 0;
@@ -614,69 +598,91 @@ shutdown(void)
         }
 
         /* HUP all local clients to allow them to clean up */
-        errno = 0;
-        if ((killpg(clientpid, SIGHUP) != 0) &&
-            (errno != ESRCH))
-            Error("can't send HUP to process group %d\r\n",
-                  clientpid);
+        if (killpg(clientpid, SIGHUP) < 0 && errno != ESRCH)
+            Error("can't send HUP to process group %d", clientpid);
     }
 
     if (serverpid < 0)
         return;
-    errno = 0;
+
     if (killpg(serverpid, SIGTERM) < 0) {
-        if (errno == EPERM)
-            Fatal("Can't kill X server\r\n");
         if (errno == ESRCH)
             return;
+        Fatal("can't kill X server");
     }
-    if (! processTimeout(10, "X server to shut down")) {
-        fprintf(stderr, "\r\n");
+
+    if (!processTimeout(10, "X server to shut down"))
         return;
-    }
 
-    fprintf(stderr,
-            "\r\n%s:  X server slow to shut down, sending KILL signal.\r\n",
-            program);
-    fflush(stderr);
-    errno = 0;
+    Errorx("X server slow to shut down, senging KILL signal");
+
     if (killpg(serverpid, SIGKILL) < 0) {
         if (errno == ESRCH)
             return;
+        Error("can't SIGKILL X server");
     }
-    if (processTimeout(3, "server to die")) {
-        fprintf(stderr, "\r\n");
-        Fatal("Can't kill server\r\n");
-    }
-    fprintf(stderr, "\r\n");
-    return;
+
+    if (processTimeout(3, "server to die"))
+        Fatalx("X server refuses to die");
 }
 
 static void
 set_environment(void)
 {
-    if (setenv("DISPLAY", displayNum, TRUE) == -1) {
-	fprintf(stderr, "%s:  unable to set DISPLAY\n", program);
-	exit(EXIT_FAILURE);
-    }
+    if (setenv("DISPLAY", displayNum, TRUE) == -1)
+        Fatal("unable to set DISPLAY");
+}
+
+static void
+verror(const char *fmt, va_list ap)
+{
+    fprintf(stderr, "%s: ", program);
+    vfprintf(stderr, fmt, ap);
+    fprintf(stderr, ": %s\n", strerror(errno));
+}
+
+static void
+verrorx(const char *fmt, va_list ap)
+{
+    fprintf(stderr, "%s: ", program);
+    vfprintf(stderr, fmt, ap);
+    fprintf(stderr, "\n");
 }
 
 static void
-Fatal(char *msg)
+Fatal(const char *fmt, ...)
 {
-    Error(msg);
+    va_list ap;
+    va_start(ap, fmt);
+    verror(fmt, ap);
+    va_end(ap);
     exit(EXIT_FAILURE);
 }
 
 static void
-Error(char *fmt, ...)
+Fatalx(const char *fmt, ...)
 {
     va_list ap;
+    va_start(ap, fmt);
+    verrorx(fmt, ap);
+    va_end(ap);
+    exit(EXIT_FAILURE);
+}
 
+static void
+Error(const char *fmt, ...)
+{
+    va_list ap;
     va_start(ap, fmt);
-    fprintf(stderr, "%s:  ", program);
-    if (errno > 0)
-        fprintf(stderr, "%s (errno %d):  ", strerror(errno), errno);
-    vfprintf(stderr, fmt, ap);
+    verror(fmt, ap);
+    va_end(ap);
+}
+
+static void
+Errorx(const char *fmt, ...)
+{
+    va_list ap;
+    va_start(ap, fmt);
+    verrorx(fmt, ap);
     va_end(ap);
 }

commit 3676185a3e3bf1e57362ed4978825d9d6d53592c
Author: Mikhail Gusarov <dottedmag@dottedmag.net>
Date:   Wed Apr 14 03:03:28 2010 +0700

    Fix comment indentation
    
    Signed-off-by: Mikhail Gusarov <dottedmag@dottedmag.net>
    Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>

diff --git a/xinit.c b/xinit.c
index 13960dd..cb622a2 100644
--- a/xinit.c
+++ b/xinit.c
@@ -337,7 +337,7 @@ waitforserver(void)
      * want to sleep now since we're going to sleep later anyways and this allows us
      * to avoid the awkard, "why is there an error message in the log" questions
      * from users.
-         */
+     */
 
     sleep(2);
 #endif

commit c0f6753d2de16826300a04232e54fbd3aa54c406
Author: Mikhail Gusarov <dottedmag@dottedmag.net>
Date:   Wed Apr 14 03:03:27 2010 +0700

    Use signals from Unix98 and drop pre-POSIX compatibility
    
    Signed-off-by: Mikhail Gusarov <dottedmag@dottedmag.net>
    Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>

diff --git a/configure.ac b/configure.ac
index 0ead99d..8930b39 100644
--- a/configure.ac
+++ b/configure.ac
@@ -40,8 +40,6 @@ AC_PROG_INSTALL
 AC_PATH_PROG(SED,sed)
 AC_CANONICAL_HOST
 
-AC_TYPE_SIGNAL
-
 m4_ifdef([AS_HELP_STRING], , [m4_define([AS_HELP_STRING], m4_defn([AC_HELP_STRING]))])
 
 
diff --git a/xinit.c b/xinit.c
index eaf4da1..13960dd 100644
--- a/xinit.c
+++ b/xinit.c
@@ -35,20 +35,7 @@ in this Software without prior written authorization from The Open Group.
 #include <ctype.h>
 #include <stdint.h>
 
-#ifdef X_POSIX_C_SOURCE
-#define _POSIX_C_SOURCE X_POSIX_C_SOURCE
 #include <signal.h>
-#undef _POSIX_C_SOURCE
-#else
-#if defined(X_NOT_POSIX) || defined(_POSIX_SOURCE)
-#include <signal.h>
-#else
-#define _POSIX_SOURCE
-#include <signal.h>
-#undef _POSIX_SOURCE
-#endif
-#endif
-
 #include <sys/wait.h>
 #include <errno.h>
 #include <setjmp.h>
@@ -125,18 +112,14 @@ static void set_environment(void);
 static void Fatal(char *msg);
 static void Error(char *fmt, ...);
 
-#ifdef RETSIGTYPE /* autoconf AC_TYPE_SIGNAL */
-# define SIGVAL RETSIGTYPE
-#endif /* RETSIGTYPE */
-
-static SIGVAL
+static void
 sigCatch(int sig)
 {
     /* On system with POSIX signals, just interrupt the system call */
     gotSignal = sig;
 }
 
-static SIGVAL
+static void
 sigIgnore(int sig)
 {
 }

commit 15cf3d560ab5b6847d8891208080ac964c1682fb
Author: Mikhail Gusarov <dottedmag@dottedmag.net>
Date:   Wed Apr 14 03:03:26 2010 +0700

    Use sigaction(2) instead of signal(2) to handle SIGUSR1 and SIGALRM
    
    Signed-off-by: Mikhail Gusarov <dottedmag@dottedmag.net>
    Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>

diff --git a/xinit.c b/xinit.c
index 66d5475..eaf4da1 100644
--- a/xinit.c
+++ b/xinit.c
@@ -137,19 +137,8 @@ sigCatch(int sig)
 }
 
 static SIGVAL
-sigAlarm(int sig)
+sigIgnore(int sig)
 {
-#if defined(SYSV) || defined(SVR4) || defined(linux) || defined(__APPLE__)
-    signal(sig, sigAlarm);
-#endif
-}
-
-static SIGVAL
-sigUsr1(int sig)
-{
-#if defined(SYSV) || defined(SVR4) || defined(linux) || defined(__APPLE__)
-    signal(sig, sigUsr1);
-#endif
 }
 
 static void
@@ -174,7 +163,7 @@ main(int argc, 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;
-    struct sigaction sa;
+    struct sigaction sa, si;
 #ifdef __APPLE__
 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
     vproc_transaction_t vt;
@@ -301,8 +290,13 @@ main(int argc, char *argv[])
     sigaction(SIGHUP, &sa, NULL);
     sigaction(SIGPIPE, &sa, NULL);
 
-    signal(SIGALRM, sigAlarm);
-    signal(SIGUSR1, sigUsr1);
+    memset(&si, 0, sizeof(si));
+    si.sa_handler = sigIgnore;
+    sigemptyset(&si.sa_mask);
+    si.sa_flags = SA_RESTART;
+
+    sigaction(SIGALRM, &si, NULL);
+    sigaction(SIGUSR1, &si, NULL);
 
 #ifdef __APPLE__
 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060

commit fa009dcc191e1d70937e5fb4dd8ae8d9c151a607
Author: Mikhail Gusarov <dottedmag@dottedmag.net>
Date:   Wed Apr 14 03:03:25 2010 +0700

    sys/wait.h is in Unix98
    
    Signed-off-by: Mikhail Gusarov <dottedmag@dottedmag.net>
    Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>

diff --git a/xinit.c b/xinit.c
index 120a772..66d5475 100644
--- a/xinit.c
+++ b/xinit.c
@@ -49,9 +49,7 @@ in this Software without prior written authorization from The Open Group.
 #endif
 #endif
 
-#ifndef SYSV
 #include <sys/wait.h>
-#endif
 #include <errno.h>
 #include <setjmp.h>
 #include <stdarg.h>

commit a13649f91f3856040f53c47d14a2cccff943c702
Author: Mikhail Gusarov <dottedmag@dottedmag.net>
Date:   Wed Apr 14 03:03:24 2010 +0700

    setpriority and PRIO_PROCESS are in Unix98
    
    Signed-off-by: Mikhail Gusarov <dottedmag@dottedmag.net>
    Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>

diff --git a/xinit.c b/xinit.c
index b89bae8..120a772 100644
--- a/xinit.c
+++ b/xinit.c
@@ -469,9 +469,7 @@ startServer(char *server[])
         /*
          * don't nice server
          */
-#ifdef PRIO_PROCESS
         setpriority(PRIO_PROCESS, serverpid, -1);
-#endif
 
         errno = 0;
         if(! processTimeout(0, "")) {


Reply to: