summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--configure.ac6
-rw-r--r--launchd/Makefile.am4
-rw-r--r--launchd/org.x.X11.plist.cpp7
-rw-r--r--launchd/x11-exec.c22
-rw-r--r--xinit.c27
5 files changed, 43 insertions, 23 deletions
diff --git a/configure.ac b/configure.ac
index 34f021e..1413595 100644
--- a/configure.ac
+++ b/configure.ac
@@ -107,11 +107,11 @@ fi
if test "x$LAUNCHD" = "xyes" ; then
AC_DEFINE(HAVE_LAUNCHD, 1, [launchd support available])
- # For now, this is how we find X11.app on OS-X...
- # A future version of launchd should let us do this cleaner
case $host_os in
darwin*)
- XSERVER=\'\`'$(libexecdir)/x11-exec'\`\'
+ # For now, this is how we find X11.app on OS-X...
+ # A future version of launchd should let us do this cleaner
+ #XSERVER=\'\`'$(libexecdir)/x11-exec'\`\'
AM_CONDITIONAL(APPLE, true)
;;
esac
diff --git a/launchd/Makefile.am b/launchd/Makefile.am
index 6a420e6..b841df8 100644
--- a/launchd/Makefile.am
+++ b/launchd/Makefile.am
@@ -6,7 +6,9 @@ endif
launchagents_PRE = org.x.X11.plist.pre
launchagents_DATA = $(launchagents_PRE:plist.pre=plist)
-CPP_FILES_FLAGS = -D__bindir__="$(bindir)"
+CPP_FILES_FLAGS = \
+ -D__libexecdir__="$(libexecdir)" \
+ -D__bindir__="$(bindir)"
CLEANFILES = $(launchagents_DATA)
diff --git a/launchd/org.x.X11.plist.cpp b/launchd/org.x.X11.plist.cpp
index 822f1f7..6aed8d8 100644
--- a/launchd/org.x.X11.plist.cpp
+++ b/launchd/org.x.X11.plist.cpp
@@ -6,9 +6,12 @@
<string>org.x.X11</string>
<key>ProgramArguments</key>
<array>
- <string>__bindir__/startx</string>
- <string>--</string>
+#ifdef __APPLE__
+ <string>__libexecdir__/x11-exec</string>
<string>-launchd</string>
+#else
+ <string>__bindir__/startx</string>
+#endif
</array>
<key>Sockets</key>
<dict>
diff --git a/launchd/x11-exec.c b/launchd/x11-exec.c
index 60e3934..bc1a233 100644
--- a/launchd/x11-exec.c
+++ b/launchd/x11-exec.c
@@ -30,6 +30,7 @@
#include <CoreServices/CoreServices.h>
#include <stdio.h>
+#include <unistd.h>
#define kX11AppBundleId "org.x.X11"
#define kX11AppBundlePath "/Contents/MacOS/X11"
@@ -53,16 +54,31 @@ int main(int argc, char **argv) {
exit(2);
}
- printf("%s/%s\n", x11_path, kX11AppBundlePath);
+ strlcat(x11_path, kX11AppBundlePath, sizeof(x11_path));
+ fprintf(stderr, "X11.app = %s\n", x11_path);
- exit(0);
+ args = (char**)malloc(sizeof (char*) * (argc + 1));
+ if (args) {
+ int i;
+ args[0] = x11_path;
+ for (i = 1; i < argc; ++i) {
+ args[i] = argv[i];
+ }
+ args[i] = NULL;
+ }
+
+ execv(x11_path, args);
+
+ fprintf(stderr, "Error executing X11.app (%s):", x11_path);
+ perror(NULL);
+ exit(3);
break;
case kLSApplicationNotFoundErr:
fprintf(stderr, "%s: Unable to find application for %s\n", argv[0], kX11AppBundleId);
exit(4);
default:
fprintf(stderr, "%s: Unable to find application for %s, error code = %d\n",
- argv[0], kX11AppBundleId, osstatus);
+ argv[0], kX11AppBundleId, (int)osstatus);
exit(5);
}
/* not reached */
diff --git a/xinit.c b/xinit.c
index e4bdc6d..be06ad1 100644
--- a/xinit.c
+++ b/xinit.c
@@ -160,16 +160,16 @@ char xserverrcbuf[256];
#define OK_EXIT 0
#define ERR_EXIT 1
-char *default_server = "X";
-char *default_display = ":0"; /* choose most efficient */
-char *default_client[] = {"xterm", "-geometry", "+1+1", "-n", "login", NULL};
-char *serverargv[100];
-char *clientargv[100];
-char **server = serverargv + 2; /* make sure room for sh .xserverrc args */
-char **client = clientargv + 2; /* make sure room for sh .xinitrc args */
-char *displayNum;
-char *program;
-Display *xd; /* server connection */
+static char *default_server = "X";
+static char *default_display = ":0"; /* choose most efficient */
+static char *default_client[] = {"xterm", "-geometry", "+1+1", "-n", "login", NULL};
+static char *serverargv[100];
+static char *clientargv[100];
+static char **server = serverargv + 2; /* make sure room for sh .xserverrc args */
+static char **client = clientargv + 2; /* make sure room for sh .xinitrc args */
+static char *displayNum = NULL;
+static char *program = NULL;
+static Display *xd = NULL; /* server connection */
#ifndef SYSV
#if defined(__CYGWIN__) || defined(SVR4) || defined(_POSIX_SOURCE) || defined(CSRG_BASED) || defined(__UNIXOS2__) || defined(Lynx) || defined(__APPLE__)
int status;
@@ -206,7 +206,7 @@ sigCatch(int sig)
static SIGVAL
sigAlarm(int sig)
{
-#if defined(SYSV) || defined(SVR4) || defined(linux) || defined(__UNIXOS2__)
+#if defined(SYSV) || defined(SVR4) || defined(linux) || defined(__UNIXOS2__) || defined(__APPLE__)
signal (sig, sigAlarm);
#endif
}
@@ -214,7 +214,7 @@ sigAlarm(int sig)
static SIGVAL
sigUsr1(int sig)
{
-#if defined(SYSV) || defined(SVR4) || defined(linux) || defined(__UNIXOS2__)
+#if defined(SYSV) || defined(SVR4) || defined(linux) || defined(__UNIXOS2__) || defined(__APPLE__)
signal (sig, sigUsr1);
#endif
}
@@ -398,7 +398,6 @@ main(int argc, char *argv[], char *envp[])
}
}
-
/*
* put the display name into the environment
*/
@@ -815,7 +814,7 @@ set_environment(void)
{
int nenvvars;
char **newPtr, **oldPtr;
- static char displaybuf[256];
+ static char displaybuf[512];
/* count number of environment variables */
for (oldPtr = environ; *oldPtr; oldPtr++) ;