diff --git a/src/proc.cpp b/src/proc.cpp index 7028c6696..bdb0c9315 100644 --- a/src/proc.cpp +++ b/src/proc.cpp @@ -984,16 +984,18 @@ int proc_format_status(int status) { } void proc_sanity_check() { - job_t *fg_job = NULL; + job_t *j; + job_t *fg_job = 0; job_iterator_t jobs; - while (job_t *j = jobs.next()) { + while ((j = jobs.next())) { + if (!job_get_flag(j, JOB_CONSTRUCTED)) continue; // More than one foreground job? if (job_get_flag(j, JOB_FOREGROUND) && !(job_is_stopped(j) || job_is_completed(j))) { - if (fg_job) { + if (fg_job != 0) { debug(0, _(L"More than one job in foreground: job 1: '%ls' job 2: '%ls'"), fg_job->command_wcstr(), j->command_wcstr()); sanity_lose(); diff --git a/src/sanity.cpp b/src/sanity.cpp index b5c803304..df355935b 100644 --- a/src/sanity.cpp +++ b/src/sanity.cpp @@ -12,18 +12,19 @@ #include "sanity.h" /// Status from earlier sanity checks. -static bool insane = false; +static int insane; void sanity_lose() { debug(0, _(L"Errors detected, shutting down. Break on sanity_lose() to debug.")); - insane = true; + insane = 1; } -bool sanity_check() { +int sanity_check() { if (!insane && shell_is_interactive()) history_sanity_check(); if (!insane) reader_sanity_check(); if (!insane) kill_sanity_check(); if (!insane) proc_sanity_check(); + return insane; } diff --git a/src/sanity.h b/src/sanity.h index 4c8c27b4e..6eedb08f0 100644 --- a/src/sanity.h +++ b/src/sanity.h @@ -6,7 +6,7 @@ void sanity_lose(); /// Perform sanity checks, return 1 if program is in a sane state 0 otherwise. -bool sanity_check(); +int sanity_check(); /// Try and determine if ptr is a valid pointer. If not, loose sanity. ///