diff --git a/src/main.c b/src/main.c index 8399d9e5..495e4d00 100644 --- a/src/main.c +++ b/src/main.c @@ -1646,7 +1646,7 @@ int main(int argc, char *argv[]) { /* * Check command specifications. */ - if (str->f) + if (str->f || str->x) continue; rv = LSOF_SEARCH_FAILURE; if (Fverbose) { diff --git a/tests/case-20-exit-status.bash b/tests/case-20-exit-status.bash index ee6b46e9..2ec0923f 100755 --- a/tests/case-20-exit-status.bash +++ b/tests/case-20-exit-status.bash @@ -53,6 +53,18 @@ f=/tmp/lsof-${name}-$$ exit 1 ;; esac + # Excluded commands are not search targets and must not cause failures. + output=$("$lsof" -a -p $$ -c '^LTNoMatch' -V -Fp) + s=$? + if [ "$s" -ne 0 ] || [ "$output" != "p$$" ]; then + echo "command exclusion: expected status 0 and p$$, got $s: $output" + exit 1 + fi + # A missing inclusion must still fail even when an exclusion is present. + "$lsof" -a -p $$ -c LTNoMatch -c '^sleep' > /dev/null + s=$? + if [ "$s" -ne 1 ]; then + echo "missing command inclusion: expected status 1, got $s" + exit 1 + fi } > $report 2>&1 - -