diff options
author | Jon TURNEY <jon.turney@dronecode.org.uk> | 2012-03-05 22:16:33 +0000 |
---|---|---|
committer | Jon TURNEY <jon.turney@dronecode.org.uk> | 2014-01-03 01:49:03 +0000 |
commit | db9449d9545451993b939e8373a3863601ee8054 (patch) | |
tree | fc121efdb50fb176ae09771c59344fa415976d77 /os | |
parent | 78a3fcb8c7d319366d865d5f4b7ad02cad497dd2 (diff) |
Use spawnl() rather than pipe() & fork() to invoke xkbcomp
Implement System() specially on Cygwin not to use fork() and exec(), but
spawnl()
Use System() and a temp file rather than pipe() & fork() to invoke xkbcomp on
cygwin, just as done on mingw
Somewhat the counsel of despair, but sometimes Windows is being such a little
bitch that the cygwin DLL just can't emulate fork() successfully, so just using
spawnl() here is more robust and means I don't have to deal with end-users
reporting this as a problem with the xserver
Popen is not used, but must be built as it is referenced by sdksyms
v2: Update to include fix to Win32TempDir() when TMP is set but TEMP isn't
XXX: Really this should check TMPDIR first, as that's the canonical UNIX way to
set the temporary directory?
v3: Fix implicit-function-declaration of Win32TempDir() in XkbDDXCompileKeymapByNames()
Add a prototype for Win32TempDir()
Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
Diffstat (limited to 'os')
-rw-r--r-- | os/utils.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/os/utils.c b/os/utils.c index 04642f703..0a3aa572d 100644 --- a/os/utils.c +++ b/os/utils.c @@ -1337,6 +1337,26 @@ OsAbort(void) * as well. As it is now, xkbcomp messages don't end up in the log file. */ +#ifdef __CYGWIN__ +#include <process.h> +int +System(const char *command) +{ + int status; + + if (!command) + return 1; + + DebugF("System: `%s'\n", command); + + /* + Use spawnl() rather than execl() to implement System() on cygwin to + avoid fork emulation overhead and brittleness + */ + status = spawnl(_P_WAIT, "/bin/sh", "sh", "-c", command, (char *) NULL); + return status; +} +#else int System(const char *command) { @@ -1378,6 +1398,7 @@ System(const char *command) return p == -1 ? -1 : status; } +#endif static struct pid { struct pid *next; @@ -1689,6 +1710,17 @@ System(const char *cmdline) return dwExitCode; } +#elif defined(__CYGWIN__) +const char* +Win32TempDir(void) +{ + if (getenv("TEMP") != NULL) + return getenv("TEMP"); + else if (getenv("TMP") != NULL) + return getenv("TMP"); + else + return "/tmp"; +} #endif /* |