mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-03-27 14:45:13 +08:00
improve sanity check code
This commit is contained in:
parent
3e10640c04
commit
319e65af05
@ -984,18 +984,16 @@ int proc_format_status(int status) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void proc_sanity_check() {
|
void proc_sanity_check() {
|
||||||
job_t *j;
|
job_t *fg_job = NULL;
|
||||||
job_t *fg_job = 0;
|
|
||||||
|
|
||||||
job_iterator_t jobs;
|
job_iterator_t jobs;
|
||||||
while ((j = jobs.next())) {
|
while (job_t *j = jobs.next()) {
|
||||||
|
|
||||||
if (!job_get_flag(j, JOB_CONSTRUCTED)) continue;
|
if (!job_get_flag(j, JOB_CONSTRUCTED)) continue;
|
||||||
|
|
||||||
|
|
||||||
// More than one foreground job?
|
// More than one foreground job?
|
||||||
if (job_get_flag(j, JOB_FOREGROUND) && !(job_is_stopped(j) || job_is_completed(j))) {
|
if (job_get_flag(j, JOB_FOREGROUND) && !(job_is_stopped(j) || job_is_completed(j))) {
|
||||||
if (fg_job != 0) {
|
if (fg_job) {
|
||||||
debug(0, _(L"More than one job in foreground: job 1: '%ls' job 2: '%ls'"),
|
debug(0, _(L"More than one job in foreground: job 1: '%ls' job 2: '%ls'"),
|
||||||
fg_job->command_wcstr(), j->command_wcstr());
|
fg_job->command_wcstr(), j->command_wcstr());
|
||||||
sanity_lose();
|
sanity_lose();
|
||||||
|
@ -12,19 +12,18 @@
|
|||||||
#include "sanity.h"
|
#include "sanity.h"
|
||||||
|
|
||||||
/// Status from earlier sanity checks.
|
/// Status from earlier sanity checks.
|
||||||
static int insane;
|
static bool insane = false;
|
||||||
|
|
||||||
void sanity_lose() {
|
void sanity_lose() {
|
||||||
debug(0, _(L"Errors detected, shutting down. Break on sanity_lose() to debug."));
|
debug(0, _(L"Errors detected, shutting down. Break on sanity_lose() to debug."));
|
||||||
insane = 1;
|
insane = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int sanity_check() {
|
bool sanity_check() {
|
||||||
if (!insane && shell_is_interactive()) history_sanity_check();
|
if (!insane && shell_is_interactive()) history_sanity_check();
|
||||||
if (!insane) reader_sanity_check();
|
if (!insane) reader_sanity_check();
|
||||||
if (!insane) kill_sanity_check();
|
if (!insane) kill_sanity_check();
|
||||||
if (!insane) proc_sanity_check();
|
if (!insane) proc_sanity_check();
|
||||||
|
|
||||||
return insane;
|
return insane;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
void sanity_lose();
|
void sanity_lose();
|
||||||
|
|
||||||
/// Perform sanity checks, return 1 if program is in a sane state 0 otherwise.
|
/// Perform sanity checks, return 1 if program is in a sane state 0 otherwise.
|
||||||
int sanity_check();
|
bool sanity_check();
|
||||||
|
|
||||||
/// Try and determine if ptr is a valid pointer. If not, loose sanity.
|
/// Try and determine if ptr is a valid pointer. If not, loose sanity.
|
||||||
///
|
///
|
||||||
|
Loading…
x
Reference in New Issue
Block a user