@@ -931,9 +931,10 @@ static pid_t mingw_spawnve_fd(const char *cmd, const char **argv, char **env,
931
931
const char * dir ,
932
932
int prepend_cmd , int fhin , int fhout , int fherr )
933
933
{
934
- STARTUPINFO si ;
934
+ STARTUPINFOW si ;
935
935
PROCESS_INFORMATION pi ;
936
936
struct strbuf envblk , args ;
937
+ wchar_t wcmd [MAX_PATH ], wdir [MAX_PATH ], * wargs ;
937
938
unsigned flags ;
938
939
BOOL ret ;
939
940
@@ -969,6 +970,11 @@ static pid_t mingw_spawnve_fd(const char *cmd, const char **argv, char **env,
969
970
si .hStdOutput = winansi_get_osfhandle (fhout );
970
971
si .hStdError = winansi_get_osfhandle (fherr );
971
972
973
+ if (xutftowcs_path (wcmd , cmd ) < 0 )
974
+ return -1 ;
975
+ if (dir && xutftowcs_path (wdir , dir ) < 0 )
976
+ return -1 ;
977
+
972
978
/* concatenate argv, quoting args as we go */
973
979
strbuf_init (& args , 0 );
974
980
if (prepend_cmd ) {
@@ -986,6 +992,10 @@ static pid_t mingw_spawnve_fd(const char *cmd, const char **argv, char **env,
986
992
free (quoted );
987
993
}
988
994
995
+ wargs = xmalloc ((2 * args .len + 1 ) * sizeof (wchar_t ));
996
+ xutftowcs (wargs , args .buf , 2 * args .len + 1 );
997
+ strbuf_release (& args );
998
+
989
999
if (env ) {
990
1000
int count = 0 ;
991
1001
char * * e , * * sorted_env ;
@@ -1007,12 +1017,12 @@ static pid_t mingw_spawnve_fd(const char *cmd, const char **argv, char **env,
1007
1017
}
1008
1018
1009
1019
memset (& pi , 0 , sizeof (pi ));
1010
- ret = CreateProcess ( cmd , args . buf , NULL , NULL , TRUE, flags ,
1011
- env ? envblk .buf : NULL , dir , & si , & pi );
1020
+ ret = CreateProcessW ( wcmd , wargs , NULL , NULL , TRUE, flags ,
1021
+ env ? envblk .buf : NULL , dir ? wdir : NULL , & si , & pi );
1012
1022
1013
1023
if (env )
1014
1024
strbuf_release (& envblk );
1015
- strbuf_release ( & args );
1025
+ free ( wargs );
1016
1026
1017
1027
if (!ret ) {
1018
1028
errno = ENOENT ;
0 commit comments