summaryrefslogtreecommitdiffstats
path: root/byterun/sys.c
diff options
context:
space:
mode:
authorXavier Leroy <xavier.leroy@inria.fr>2003-03-24 15:24:51 +0000
committerXavier Leroy <xavier.leroy@inria.fr>2003-03-24 15:24:51 +0000
commitbba3cef902df56ae74dc1b26bdba973b43f66e93 (patch)
tree17b9b1842722c2cdcabc5d04d9426a865af4d27a /byterun/sys.c
parenta6a2c80153ca69ba4ecf0cff14cca58a56fdb165 (diff)
La gestion des @responsefile est maintenant faite en Caml. Penser a liberer le buffer utilise par system().
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@5450 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'byterun/sys.c')
-rw-r--r--byterun/sys.c17
1 files changed, 7 insertions, 10 deletions
diff --git a/byterun/sys.c b/byterun/sys.c
index 01184b908..e6e05e317 100644
--- a/byterun/sys.c
+++ b/byterun/sys.c
@@ -254,14 +254,15 @@ void sys_init(char * exe_name, char **argv)
caml_main_argv = argv;
}
+#ifdef _WIN32
+#define WIFEXITED(status) 1
+#define WEXITSTATUS(status) (status)
+#else
#if !(defined(WIFEXITED) && defined(WEXITSTATUS))
/* Assume old-style V7 status word */
#define WIFEXITED(status) (((status) & 0xFF) == 0)
#define WEXITSTATUS(status) (((status) >> 8) & 0xFF)
#endif
-
-#ifdef _WIN32
-extern int win32_system(char * command);
#endif
CAMLprim value sys_system_command(value command)
@@ -274,19 +275,15 @@ CAMLprim value sys_system_command(value command)
len = string_length (command);
buf = stat_alloc (len + 1);
memmove (buf, String_val (command), len + 1);
-
enter_blocking_section ();
-#ifndef _WIN32
status = system(buf);
+ leave_blocking_section ();
+ stat_free(buf);
+ if (status == -1) sys_error(command);
if (WIFEXITED(status))
retcode = WEXITSTATUS(status);
else
retcode = 255;
-#else
- status = retcode = win32_system(buf);
-#endif
- leave_blocking_section ();
- if (status == -1) sys_error(command);
CAMLreturn (Val_int(retcode));
}