diff options
author | Lennart Poettering <lennart@poettering.net> | 2015-04-28 18:24:20 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2015-04-28 21:34:23 +0200 |
commit | 597466f49752a52e85ea04051d020f97e8739f72 (patch) | |
tree | b8db897a9af2741644e4deafdc0b11094b95edb9 /src/shared/exit-status.c | |
parent | 68a01fb658c926b527bd58da94467903feb5d1d0 (diff) |
exit-status: introduce common exit_status_set_test() call for testing exit status set membership
Diffstat (limited to 'src/shared/exit-status.c')
-rw-r--r-- | src/shared/exit-status.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/shared/exit-status.c b/src/shared/exit-status.c index 9e14eb8bf5..c09efdd2cb 100644 --- a/src/shared/exit-status.c +++ b/src/shared/exit-status.c @@ -225,3 +225,17 @@ bool exit_status_set_is_empty(ExitStatusSet *x) { return set_isempty(x->status) && set_isempty(x->signal); } + +bool exit_status_set_test(ExitStatusSet *x, int code, int status) { + + if (exit_status_set_is_empty(x)) + return false; + + if (code == CLD_EXITED && set_contains(x->status, INT_TO_PTR(status))) + return true; + + if (IN_SET(code, CLD_KILLED, CLD_DUMPED) && set_contains(x->signal, INT_TO_PTR(status))) + return true; + + return false; +} |