From 88b782fb0e7ad26c8363eda5c850e5eba6acb445 Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Sat, 8 Dec 2018 08:50:37 +0000 Subject: win32: allow execution of empty batch file to succeed Microsoft Windows' spawnve returns ERROR_BAD_EXE_FORMAT when passed an empty batch file. Work around this by skipping spawnve and returning success. --- win32/process.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'win32') diff --git a/win32/process.c b/win32/process.c index fda38318a..f059bee18 100644 --- a/win32/process.c +++ b/win32/process.c @@ -237,6 +237,13 @@ spawnveq(int mode, const char *path, char *const *argv, char *const *env) if (*s == '/') *s = '\\'; } + + /* Another special case: spawnve returns ENOEXEC when passed an + * empty batch file. Pretend it worked. */ + if (st.st_size == 0) { + ret = 0; + goto done; + } } /* @@ -250,6 +257,7 @@ spawnveq(int mode, const char *path, char *const *argv, char *const *env) ret = spawnve(mode, new_path ? new_path : path, new_argv, env); + done: for (i = 0;i < argc;i++) if (new_argv[i] != argv[i]) free(new_argv[i]); -- cgit v1.2.3-55-g6feb