mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-20 05:41:14 -03:00
Remove abstractions around job list
Directly access the job list without the intermediate job_iterator_t, and remove functions that are ripe for abuse by modifying a local enumeration of the same list instead of operating on the iterators directly (e.g. proc.cpp iterates jobs, and mid-iteration calls parser::job_remove(j) with the job (and not the iterator to the job), causing an invisible invalidation of the pre-existing local iterators.
This commit is contained in:
@@ -570,19 +570,6 @@ void parser_t::job_add(shared_ptr<job_t> job) {
|
||||
this->my_job_list.push_front(std::move(job));
|
||||
}
|
||||
|
||||
bool parser_t::job_remove(job_t *job) {
|
||||
for (auto iter = my_job_list.begin(); iter != my_job_list.end(); ++iter) {
|
||||
if (iter->get() == job) {
|
||||
my_job_list.erase(iter);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
debug(1, _(L"Job inconsistency"));
|
||||
sanity_lose();
|
||||
return false;
|
||||
}
|
||||
|
||||
void parser_t::job_promote(job_t *job) {
|
||||
job_list_t::iterator loc;
|
||||
for (loc = my_job_list.begin(); loc != my_job_list.end(); ++loc) {
|
||||
@@ -604,20 +591,17 @@ job_t *parser_t::job_get(job_id_t id) {
|
||||
}
|
||||
|
||||
job_t *parser_t::job_get_from_pid(pid_t pid) const {
|
||||
job_iterator_t jobs;
|
||||
job_t *job;
|
||||
|
||||
pid_t pgid = getpgid(pid);
|
||||
|
||||
if (pgid == -1) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
while ((job = jobs.next())) {
|
||||
for (auto job : jobs()) {
|
||||
if (job->pgid == pgid) {
|
||||
for (const process_ptr_t &p : job->processes) {
|
||||
if (p->pid == pid) {
|
||||
return job;
|
||||
return job.get();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user