mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-24 14:23:52 +08:00
Make hup_background_jobs accept the job list directly
This commit is contained in:
parent
59c6663a16
commit
05b8d4de97
|
@ -903,7 +903,7 @@ static bool allow_exec_with_background_jobs(parser_t &parser) {
|
|||
last_exec_run_count = current_run_count;
|
||||
return false;
|
||||
} else {
|
||||
hup_background_jobs(parser);
|
||||
hup_jobs(parser.jobs());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
13
src/proc.cpp
13
src/proc.cpp
|
@ -998,15 +998,10 @@ void proc_wait_any(parser_t &parser) {
|
|||
process_clean_after_marking(parser, parser.libdata().is_interactive);
|
||||
}
|
||||
|
||||
void hup_background_jobs(const parser_t &parser) {
|
||||
// TODO: we should probably hup all jobs across all parsers here.
|
||||
for (const auto &j : parser.jobs()) {
|
||||
// Make sure we don't try to SIGHUP the calling builtin
|
||||
if (j->pgid == INVALID_PID || !j->wants_job_control()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!j->is_completed()) {
|
||||
void hup_jobs(const job_list_t &jobs) {
|
||||
pid_t fish_pgrp = getpgrp();
|
||||
for (const auto &j : jobs) {
|
||||
if (j->pgid != INVALID_PID && j->pgid != fish_pgrp && !j->is_completed()) {
|
||||
if (j->is_stopped()) {
|
||||
j->signal(SIGCONT);
|
||||
}
|
||||
|
|
|
@ -591,8 +591,8 @@ void proc_wait_any(parser_t &parser);
|
|||
void set_is_within_fish_initialization(bool flag);
|
||||
bool is_within_fish_initialization();
|
||||
|
||||
/// Terminate all background jobs
|
||||
void hup_background_jobs(const parser_t &parser);
|
||||
/// Send SIGHUP to the list \p jobs, excepting those which are in fish's pgroup.
|
||||
void hup_jobs(const job_list_t &jobs);
|
||||
|
||||
/// Give ownership of the terminal to the specified job, if it wants it.
|
||||
///
|
||||
|
|
|
@ -2365,6 +2365,7 @@ static void handle_end_loop(const parser_t &parser) {
|
|||
}
|
||||
}
|
||||
|
||||
// Perhaps print a warning before exiting.
|
||||
reader_data_t *data = current_data();
|
||||
auto bg_jobs = jobs_requiring_warning_on_exit(parser);
|
||||
if (!data->prev_end_loop && !bg_jobs.empty()) {
|
||||
|
@ -2376,7 +2377,7 @@ static void handle_end_loop(const parser_t &parser) {
|
|||
}
|
||||
|
||||
// Kill remaining jobs before exiting.
|
||||
hup_background_jobs(parser);
|
||||
hup_jobs(parser.jobs());
|
||||
}
|
||||
|
||||
static bool selection_is_at_top() {
|
||||
|
|
Loading…
Reference in New Issue
Block a user