File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -58,6 +58,7 @@ struct exec_result do_exec(struct exec_args *args)
5858 int stdin_pipe [2 ] = {-1 , -1 };
5959 int stdout_pipe [2 ] = {-1 , -1 };
6060 int stderr_pipe [2 ] = {-1 , -1 };
61+ const char * cmd = args -> cmd ? args -> cmd : args -> argv [0 ];
6162
6263 if (pipe2 (execpipe , O_CLOEXEC ) < 0 )
6364 goto exit ;
@@ -109,7 +110,7 @@ struct exec_result do_exec(struct exec_args *args)
109110 if (args -> setsid && setsid () < 0 )
110111 goto child_err ;
111112 sigprocmask (SIG_SETMASK , & old , NULL );
112- execvp (args -> argv [ 0 ] , UNCONST (args -> argv ));
113+ execvp (cmd , UNCONST (args -> argv ));
113114child_err :
114115 saved_errno = errno ;
115116 write (execpipe [1 ], & saved_errno , sizeof saved_errno );
Original file line number Diff line number Diff line change 3333
3434struct exec_args {
3535 const char * * argv ;
36+ const char * cmd ; /* if NULL, argv[0] is used */
3637 int redirect_stdin ;
3738 int redirect_stdout ;
3839 int redirect_stderr ;
You can’t perform that action at this time.
0 commit comments