mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-26 19:03:38 +08:00
exec: Pass some cstrs as cstr instead of converting to ptr and back
This commit is contained in:
parent
7e8a4dbe5c
commit
46afbea72b
|
@ -421,7 +421,7 @@ fn safe_launch_process(
|
|||
}
|
||||
|
||||
set_errno(err);
|
||||
safe_report_exec_error(errno().0, actual_cmd.as_ptr(), argv.get(), envv.get());
|
||||
safe_report_exec_error(errno().0, actual_cmd, argv.get(), envv.get());
|
||||
exit_without_destructors(exit_code_from_exec_error(err.0));
|
||||
}
|
||||
|
||||
|
@ -721,8 +721,8 @@ fn fork_child_for_process(
|
|||
p.pid(),
|
||||
pgid,
|
||||
job.job_id().as_num(),
|
||||
narrow_cmd.as_ptr(),
|
||||
narrow_argv0.as_ptr(),
|
||||
&narrow_cmd,
|
||||
&narrow_argv0,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -858,7 +858,7 @@ fn exec_external_command(
|
|||
let pid = match pid {
|
||||
Ok(pid) => pid,
|
||||
Err(err) => {
|
||||
safe_report_exec_error(err.0, actual_cmd.as_ptr(), argv.get(), envv.get());
|
||||
safe_report_exec_error(err.0, &actual_cmd, argv.get(), envv.get());
|
||||
p.status
|
||||
.update(&ProcStatus::from_exit_code(exit_code_from_exec_error(
|
||||
err.0,
|
||||
|
|
|
@ -52,17 +52,11 @@ pub(crate) fn report_setpgid_error(
|
|||
pid: pid_t,
|
||||
desired_pgid: pid_t,
|
||||
job_id: i64,
|
||||
command_str: *const c_char,
|
||||
argv0_str: *const c_char,
|
||||
command: &CStr,
|
||||
argv0: &CStr,
|
||||
) {
|
||||
let cur_group = unsafe { libc::getpgid(pid) };
|
||||
|
||||
// TODO: command_str ought to be passed as a CStr.
|
||||
// This is worth fixing as CStr::from_ptr may invoke libc strlen() which
|
||||
// is not async signal safe on old versions of POSIX.
|
||||
let command: &CStr = unsafe { CStr::from_ptr(command_str) };
|
||||
let argv0: &CStr = unsafe { CStr::from_ptr(argv0_str) };
|
||||
|
||||
FLOG_SAFE!(
|
||||
warning,
|
||||
"Could not send ",
|
||||
|
@ -245,12 +239,10 @@ pub fn execute_fork() -> pid_t {
|
|||
|
||||
pub(crate) fn safe_report_exec_error(
|
||||
err: i32,
|
||||
actual_cmd: *const c_char,
|
||||
actual_cmd: &CStr,
|
||||
argvv: *const *const c_char,
|
||||
envv: *const *const c_char,
|
||||
) {
|
||||
// TODO: actual_cmd may be passed as a CStr.
|
||||
let actual_cmd: &CStr = unsafe { CStr::from_ptr(actual_cmd) };
|
||||
match err {
|
||||
libc::E2BIG => {
|
||||
let mut sz = 0;
|
||||
|
|
Loading…
Reference in New Issue
Block a user