summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthieu Herrb <matthieu.herrb@laas.fr>2011-08-21 15:11:41 +0200
committerMatthieu Herrb <matthieu.herrb@laas.fr>2011-08-21 15:11:41 +0200
commit44b8dbd86182495f201fc323f6b7faf1de99d990 (patch)
tree4bd2e4def15c600ad61c625f326b41da8948feff
parentf399011e5af2cf4793bf1e751ee37b11ca2057c5 (diff)
parent727706ffda344a1a752df296cd230ff3fb3940a5 (diff)
Merge remote-tracking branch 'origin/master' into obsd
-rw-r--r--launchd/user_startx/launchd_startx.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/launchd/user_startx/launchd_startx.c b/launchd/user_startx/launchd_startx.c
index e3fae76..f83cd61 100644
--- a/launchd/user_startx/launchd_startx.c
+++ b/launchd/user_startx/launchd_startx.c
@@ -34,11 +34,19 @@
#include <unistd.h>
#include <stdio.h>
#include <assert.h>
-#include <spawn.h>
#include <sys/wait.h>
#include <string.h>
#include <stdlib.h>
+/* Using MIN_REQUIRED instead of MAX_ALLOWED logic due to posix_spawn not
+ * being marked with availability macros until 10.7
+ */
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
+#include <spawn.h>
+#else
+#include <errno.h>
+#endif
+
#include "console_redirect.h"
int main(int argc, char **argv, char **envp) {
@@ -56,7 +64,19 @@ int main(int argc, char **argv, char **envp) {
xi_asl_capture_fd(aslc, NULL, ASL_LEVEL_INFO, STDOUT_FILENO);
xi_asl_capture_fd(aslc, NULL, ASL_LEVEL_NOTICE, STDERR_FILENO);
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
assert(posix_spawnp(&child, argv[1], NULL, NULL, &argv[1], envp) == 0);
+#else
+ switch(child = fork()) {
+ case -1:
+ perror("fork");
+ return errno;
+ case 0:
+ return execvp(argv[1], &argv[1]);
+ default:
+ break;
+ }
+#endif
wait4(child, &pstat, 0, (struct rusage *)0);