File tree 1 file changed +18
-11
lines changed
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> {
361
361
362
362
/// Create a new child process from the specified process image. See
363
363
/// [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 ,
366
366
file_actions : & PosixSpawnFileActions ,
367
367
attr : & PosixSpawnAttr ,
368
368
args : & [ SA ] ,
369
369
envp : & [ SE ] ,
370
- ) -> Result < Pid > {
370
+ ) -> Result < Pid >
371
+ where
372
+ P : NixPath + ?Sized ,
373
+ SA : AsRef < CStr > ,
374
+ SE : AsRef < CStr > ,
375
+ {
371
376
let mut pid = 0 ;
372
377
373
378
let ret = unsafe {
374
379
let args_p = to_exec_array ( args) ;
375
380
let env_p = to_exec_array ( envp) ;
376
381
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
+ } ) ?
385
392
} ;
386
393
387
394
if ret != 0 {
You can’t perform that action at this time.
0 commit comments