summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon TURNEY <jon.turney@dronecode.org.uk>2011-11-01 15:32:59 +0000
committerJon TURNEY <jon.turney@dronecode.org.uk>2011-11-05 16:16:44 +0000
commit20185cfd3f713a23bc9303d626c6244a570b5188 (patch)
tree7a4ce9a68574cee4b71754bbf97b0b880c0be139
parent4db7b6845d30408dc519045de2af073f3ba9e6d4 (diff)
Implement System() specially on Cygwin not to use fork/exec
Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
-rw-r--r--os/utils.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/os/utils.c b/os/utils.c
index f4b93ee57..013548437 100644
--- a/os/utils.c
+++ b/os/utils.c
@@ -1254,6 +1254,25 @@ 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(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(char *command)
{
@@ -1295,6 +1314,7 @@ System(char *command)
return p == -1 ? -1 : status;
}
+#endif
static struct pid {
struct pid *next;