This makes fstat(1) behave more like grep(1), regarding exit status. The idea itself came from bluhm@.
For manpage, I mostly copied the text from grep(1), but changed phrases talking about selected lines to matching processes. Or should those be selected processes?.. -- WBR, Vadim Zhukov Index: fstat.1 =================================================================== RCS file: /cvs/src/usr.bin/fstat/fstat.1,v retrieving revision 1.51 diff -u -p -r1.51 fstat.1 --- fstat.1 31 Jan 2015 19:33:45 -0000 1.51 +++ fstat.1 4 May 2016 01:43:05 -0000 @@ -278,6 +278,19 @@ Each .Xr systrace 4 device is printed with only the kernel address of the device private data. +.Sh EXIT STATUS +The +.Nm +utility exits with one of the following values: +.Pp +.Bl -tag -width Ds -offset indent -compact +.It Li 0 +One or more matching processes were found. +.It Li 1 +No processes matching given criteria were found. +.It Li \*(Gt1 +An error occurred. +.El .Sh SEE ALSO .Xr netstat 1 , .Xr nfsstat 1 , Index: fstat.c =================================================================== RCS file: /cvs/src/usr.bin/fstat/fstat.c,v retrieving revision 1.86 diff -u -p -r1.86 fstat.c --- fstat.c 2 Jan 2016 13:22:52 -0000 1.86 +++ fstat.c 4 May 2016 01:43:05 -0000 @@ -273,7 +273,7 @@ main(int argc, char *argv[]) } if ((kf = kvm_getfiles(kd, what, arg, sizeof(*kf), &cnt)) == NULL) - errx(1, "%s", kvm_geterr(kd)); + errx((errno == ESRCH) ? 1 : 2, "%s", kvm_geterr(kd)); if (fuser) { /*