aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew G. Morgan <morgan@kernel.org>2022-04-11 10:22:21 -0700
committerAndrew G. Morgan <morgan@kernel.org>2022-04-11 10:23:18 -0700
commit94250487ed76c64abc6bed9e58930608a168717d (patch)
treefbb6839ab5ed8f7bb847a3ae8a6e029ebb8015cf
parent38cfa2e9582794108772631bbd800de7652b05d0 (diff)
downloadlibcap-94250487ed76c64abc6bed9e58930608a168717d.tar.gz
More useful captree usage string and man page.
Include more detail about command line expectations and exit status values. Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
-rw-r--r--doc/captree.819
-rw-r--r--goapps/captree/captree.go5
2 files changed, 17 insertions, 7 deletions
diff --git a/doc/captree.8 b/doc/captree.8
index d2c0003..86a7de3 100644
--- a/doc/captree.8
+++ b/doc/captree.8
@@ -1,15 +1,15 @@
.\" Hey, EMACS: -*- nroff -*-
-.TH CAPTREE 8 "2021-09-02"
+.TH CAPTREE 8 "2022-04-11"
.\" Please adjust this date whenever revising the manpage.
.SH NAME
-captree \- display process tree capabilities
+captree \- display tree of process capabilities
.SH SYNOPSIS
-.BR captree " [optional args] "
-.IR [pid|glob-name ... ]
+.BR captree " [OPTIONS] "
+.RI [( pid | glob-name ") ...]"
.SH DESCRIPTION
.B captree
displays the capabilities on the mentioned processes indicated by
-.IR pid or glob-name
+.IR pid " or " glob-name
value(s) given on the command line. If no
.I pid
etc values are supplied,
@@ -34,7 +34,8 @@ Optional arguments (which must precede the list of pid|glob-name
values):
.TP
.B \-\-help
-Displays usage information and exits.
+Displays usage information and exits. Note, modern Go runtimes exit
+with status 0 in this case, but older runtimes exit with status 2.
.TP
.BR \-\-verbose
Displays capability sets and IAB tuples even when they are empty, or
@@ -51,7 +52,11 @@ Colo[u]rs the targeted PIDs, if stdout is a TTY, in red. This option
defaults to true when running via a TTY. The \fB--color\fI=false\fR
argument will suppress this color. Piping the output into some other
program will also suppress the use of colo[u]r.
-
+.SH EXIT STATUS
+If the supplied target cannot be found the exit status is 1. Should an
+unrecognized option be provided, the exit status is 2. Otherwise,
+.B captree
+exits with status 0.
.SH REPORTING BUGS
Please report bugs via:
.TP
diff --git a/goapps/captree/captree.go b/goapps/captree/captree.go
index fc89b51..5313cb4 100644
--- a/goapps/captree/captree.go
+++ b/goapps/captree/captree.go
@@ -340,6 +340,7 @@ func findPIDs(list []string, pids map[string]*task, glob string) <-chan string {
return
}
fmt.Printf("no process matched %q\n", glob)
+ os.Exit(1)
}()
return finds
}
@@ -356,6 +357,10 @@ func setDepth(pids map[string]*task, pid string) int {
}
func main() {
+ flag.Usage = func() {
+ fmt.Fprintf(flag.CommandLine.Output(), "Usage: %s [options] [pid|glob] ...\nOptions:\n", os.Args[0])
+ flag.PrintDefaults()
+ }
flag.Parse()
// Honor the command line request if possible.