File tree Expand file tree Collapse file tree 1 file changed +18
-11
lines changed Expand file tree Collapse file tree 1 file changed +18
-11
lines changed Original file line number Diff line number Diff line change @@ -361,27 +361,34 @@ unsafe fn to_exec_array<S: AsRef<CStr>>(args: &[S]) -> Vec<*mut libc::c_char> {
361361
362362/// Create a new child process from the specified process image. See
363363/// [posix_spawn](https://pubs.opengroup.org/onlinepubs/9699919799/functions/posix_spawn.html).
364- pub fn posix_spawn < SA : AsRef < CStr > , SE : AsRef < CStr > > (
365- path : & CStr ,
364+ pub fn posix_spawn < P , SA , SE > (
365+ path : & P ,
366366 file_actions : & PosixSpawnFileActions ,
367367 attr : & PosixSpawnAttr ,
368368 args : & [ SA ] ,
369369 envp : & [ SE ] ,
370- ) -> Result < Pid > {
370+ ) -> Result < Pid >
371+ where
372+ P : NixPath + ?Sized ,
373+ SA : AsRef < CStr > ,
374+ SE : AsRef < CStr > ,
375+ {
371376 let mut pid = 0 ;
372377
373378 let ret = unsafe {
374379 let args_p = to_exec_array ( args) ;
375380 let env_p = to_exec_array ( envp) ;
376381
377- libc:: posix_spawn (
378- & mut pid as * mut libc:: pid_t ,
379- path. as_ptr ( ) ,
380- & file_actions. fa as * const libc:: posix_spawn_file_actions_t ,
381- & attr. attr as * const libc:: posix_spawnattr_t ,
382- args_p. as_ptr ( ) ,
383- env_p. as_ptr ( ) ,
384- )
382+ path. with_nix_path ( |c_str| {
383+ libc:: posix_spawn (
384+ & mut pid as * mut libc:: pid_t ,
385+ c_str. as_ptr ( ) ,
386+ & file_actions. fa as * const libc:: posix_spawn_file_actions_t ,
387+ & attr. attr as * const libc:: posix_spawnattr_t ,
388+ args_p. as_ptr ( ) ,
389+ env_p. as_ptr ( ) ,
390+ )
391+ } ) ?
385392 } ;
386393
387394 if ret != 0 {
You can’t perform that action at this time.
0 commit comments