mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-11 01:06:01 +03:00
Shell: Use kill_job() to kill jobs
This commit is contained in:
parent
384e872ff9
commit
c92865bd05
Notes:
sideshowbarker
2024-07-19 01:39:48 +09:00
Author: https://github.com/alimpfard Commit: https://github.com/SerenityOS/serenity/commit/c92865bd059 Pull-request: https://github.com/SerenityOS/serenity/pull/3858
@ -1580,11 +1580,12 @@ Shell::~Shell()
|
||||
void Shell::stop_all_jobs()
|
||||
{
|
||||
if (!jobs.is_empty()) {
|
||||
printf("Killing active jobs\n");
|
||||
if (m_is_interactive && !m_is_subshell)
|
||||
printf("Killing active jobs\n");
|
||||
for (auto& entry : jobs) {
|
||||
if (!entry.value->is_running_in_background()) {
|
||||
if (entry.value->is_suspended()) {
|
||||
#ifdef SH_DEBUG
|
||||
dbg() << "Job " << entry.value->pid() << " is not running in background";
|
||||
dbg() << "Job " << entry.value->pid() << " is suspended";
|
||||
#endif
|
||||
kill_job(entry.value, SIGCONT);
|
||||
}
|
||||
@ -1598,11 +1599,7 @@ void Shell::stop_all_jobs()
|
||||
#ifdef SH_DEBUG
|
||||
dbg() << "Actively killing " << entry.value->pid() << "(" << entry.value->cmd() << ")";
|
||||
#endif
|
||||
if (killpg(entry.value->pgid(), SIGKILL) < 0) {
|
||||
if (errno == ESRCH)
|
||||
continue; // The process has exited all by itself.
|
||||
perror("killpg(KILL)");
|
||||
}
|
||||
kill_job(entry.value, SIGKILL);
|
||||
}
|
||||
|
||||
jobs.clear();
|
||||
@ -1633,8 +1630,11 @@ void Shell::kill_job(const Job* job, int sig)
|
||||
if (!job)
|
||||
return;
|
||||
|
||||
if (killpg(job->pgid(), sig) < 0)
|
||||
perror("killpg(job)");
|
||||
if (killpg(job->pgid(), sig) < 0) {
|
||||
if (kill(job->pid(), sig) < 0) {
|
||||
perror("kill");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Shell::save_to(JsonObject& object)
|
||||
|
Loading…
Reference in New Issue
Block a user