Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions brush-builtins/src/kill.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,15 @@ impl builtins::Command for KillCommand {
}
} else {
let pid = brush_core::int_utils::parse(pid_or_job_spec.as_str(), 10)?;
let is_self_signal =
i32::try_from(std::process::id()).is_ok_and(|current_pid| current_pid == pid);

if is_self_signal && context.shell.traps().handles(trap_signal) {
if let Ok(signal_number) = i32::try_from(trap_signal) {
context.params.request_host_signal(signal_number);
return Ok(ExecutionResult::success());
}
}

// It's a pid.
sys::signal::kill_process(pid, trap_signal)?;
Expand Down
3 changes: 3 additions & 0 deletions brush-core/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -614,13 +614,16 @@ pub(crate) fn execute_external_command(
cmd.process_group(0);
if child_stdin_is_terminal {
cmd.take_foreground();
} else {
cmd.reset_job_control_signals();
}
}
} else {
// We need to join an established process group.
if let Some(pgid) = process_group_id {
cmd.process_group(pgid);
}
cmd.reset_job_control_signals();
}

// When tracing is enabled, report.
Expand Down
Loading
Loading