From 4e56b01e9ea31f312d26cc59b4cf5ca56c8046f3 Mon Sep 17 00:00:00 2001 From: Jonas 'Sortie' Termansen Date: Sun, 17 Apr 2022 23:17:23 +0200 Subject: [PATCH] Fix getopt error handling in pstree(1). --- utils/pstree.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/utils/pstree.c b/utils/pstree.c index 858e757a..7ea70ff6 100644 --- a/utils/pstree.c +++ b/utils/pstree.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016, 2021 Jonas 'Sortie' Termansen. + * Copyright (c) 2015, 2016, 2021, 2022 Jonas 'Sortie' Termansen. * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -150,11 +150,12 @@ int main(int argc, char* argv[]) { case 'g': show_pgid = true; break; case 'p': show_pid = true; break; + default: return 1; } } if ( optind < argc ) - errx(1, "extra operand: %s", argv[1]); + errx(1, "extra operand: %s", argv[optind]); pstree(1, "", true, show_pgid, show_pid);