Browse Source

Fix autogen.sh grep usage; update documentation; handle
KERN_PROC_ALL/KERN_PROC_PROC.

Douglas William Thrift 13 years ago
parent
commit
8cac8ede7c
8 changed files with 472 additions and 501 deletions
  1. 1 1
      GNUmakefile.in
  2. 1 1
      autogen.sh
  3. 3 2
      build-aux/install-sh
  4. 441 483
      configure
  5. 7 1
      configure.ac
  6. 5 4
      dtpstree.1.in
  7. 9 5
      dtpstree.cpp
  8. 5 4
      man1/dtpstree.1

+ 1 - 1
GNUmakefile.in

@@ -23,7 +23,7 @@ VPATH := @srcdir@
 srcdir := @srcdir@
 top_builddir := @top_builddir@
 
-CPPFLAGS := @CPPFLAGS@ $(filter -DPACKAGE_TARNAME% -DPACKAGE_VERSION% -DHAVE_NCURSES% -DHAVE_CURSES% -DHAVE_TERM% -DHAVE_STRUCT_KINFO_PROC%,@DEFS@)
+CPPFLAGS := @CPPFLAGS@ $(filter -DPACKAGE_TARNAME% -DPACKAGE_VERSION% -DHAVE_NCURSES% -DHAVE_CURSES% -DHAVE_TERM% -DHAVE_STRUCT_KINFO_PROC% -DHAVE_DECL_KERN_PROC_PROC%,@DEFS@)
 CXX := @CXX@
 CXXFLAGS := @CXXFLAGS@ -Wall -Wno-long-long -Wno-parentheses
 LDFLAGS := @LDFLAGS@

+ 1 - 1
autogen.sh

@@ -36,7 +36,7 @@ done
 aclocal
 
 for ac_m4 in ${ac_m4s[@]}; do
-	if ! grep -q "^# ${ac_m4//./\\.}$" aclocal.m4; then
+	if ! grep -qs "^# ${ac_m4//./\\.}$" aclocal.m4; then
 		echo -e "# $ac_m4\n$(<$ac_m4)" >> aclocal.m4
 	fi
 done

+ 3 - 2
build-aux/install-sh

@@ -1,7 +1,7 @@
 #!/bin/sh
 # install - install a program, script, or datafile
 
-scriptversion=2006-12-25.00
+scriptversion=2009-04-28.21; # UTC
 
 # This originates from X11R5 (mit/util/scripts/install.sh), which was
 # later released in X11R6 (xc/config/util/install.sh) with the
@@ -515,5 +515,6 @@ done
 # eval: (add-hook 'write-file-hooks 'time-stamp)
 # time-stamp-start: "scriptversion="
 # time-stamp-format: "%:y-%02m-%02d.%02H"
-# time-stamp-end: "$"
+# time-stamp-time-zone: "UTC"
+# time-stamp-end: "; # UTC"
 # End:

File diff suppressed because it is too large
+ 441 - 483
configure


+ 7 - 1
configure.ac

@@ -84,6 +84,9 @@ AC_ARG_ENABLE([terminfo],
 	)], [AS_CASE([$enableval], [no], [DT_CHECK_TERMCAP], [DT_CHECK_TERMINFO])],
 	[DT_CHECK_TERMINFO]
 )
+AC_DEFUN([DT_MSG_BSD], [AC_MSG_ERROR([You need libbsd])])
+AC_CHECK_HEADER([vis.h], [], [DT_MSG_BSD])
+AC_SEARCH_LIBS([strvis], [bsd], [], [DT_MSG_BSD])
 AC_DEFUN([DT_MSG_KVM], [AC_MSG_ERROR([You need libkvm])])
 AC_CHECK_HEADER([kvm.h], [], [DT_MSG_KVM])
 AC_SEARCH_LIBS([kvm_openfiles], [kvm], [], [DT_MSG_KVM])
@@ -112,6 +115,9 @@ AC_CHECK_TYPE([struct kinfo_proc2],
 		[DT_MSG_KVM], [DT_INCLUDES_KVM]
 	)], [DT_INCLUDES_KVM]
 )
-dnl AC_CHECK_DECLS([KERN_PROC_PROC, KERN_PROC_ALL])
+AC_CHECK_DECLS([KERN_PROC_PROC, KERN_PROC_ALL], [], [], [DT_INCLUDES_KVM])
+AS_CASE([$ac_cv_have_decl_KERN_PROC_PROC$ac_cv_have_decl_KERN_PROC_ALL],
+	[*yes*], [], [DT_MSG_KVM]
+)
 AC_CONFIG_FILES([GNUmakefile])
 AC_OUTPUT

+ 5 - 4
dtpstree.1.in

@@ -1,14 +1,15 @@
 [DESCRIPTION]
 .B dtpstree
 shows running processes as a tree. It is a reimplementation of \fBpstree\fR from
-\fIPSmisc\fR for FreeBSD, NetBSD, and OpenBSD. It also works without \fI/proc\fR
-and will show the full set of processes in a jail even if \fBinit\fR is not
-present.
+\fIPSmisc\fR for FreeBSD, NetBSD, OpenBSD, and other modern BSD variants. It
+also works without \fI/proc\fR and will show the full set of processes in a jail
+even if \fBinit\fR is not present.
 [AUTHOR]
 Written by \fBDouglas Thrift\fR <\fIdouglas@douglasthrift.net\fR>.
 [SEE ALSO]
 .PP
-\fBps\fR(1), \fBkvm\fR(3), \fBkvm_getargv\fR(3), \fBkvm_getprocs\fR(3).
+\fBps\fR(1), \fBkvm\fR(3), \fBkvm_getargv\fR(3) or \fBkvm_getargv2\fR(3),
+\fBkvm_getprocs\fR(3) or \fBkvm_getproc2\fR(3).
 [COPYRIGHT]
 .PP
 Copyright 2010 Douglas Thrift

+ 9 - 5
dtpstree.cpp

@@ -32,9 +32,7 @@
 #include <string>
 #include <vector>
 
-#ifdef __GLIBC__
-#include <bsd/stdlib.h>
-#else
+#ifndef __GLIBC__
 #include <libgen.h>
 #endif
 
@@ -65,6 +63,12 @@
 namespace kvm
 {
 
+#if HAVE_DECL_KERN_PROC_PROC
+const int All(KERN_PROC_PROC);
+#else
+const int All(KERN_PROC_ALL);
+#endif
+
 template <typename Type>
 inline Type *getprocs(kvm_t *kd, int &count);
 
@@ -91,7 +95,7 @@ const int Flags(O_RDONLY);
 template <>
 inline kinfo_proc *getprocs(kvm_t *kd, int &count)
 {
-	return kvm_getprocs(kd, KERN_PROC_PROC, 0, &count);
+	return kvm_getprocs(kd, All, 0, &count);
 }
 
 template <>
@@ -107,7 +111,7 @@ const int Flags(KVM_NO_FILES);
 template <>
 inline kinfo_proc2 *getprocs(kvm_t *kd, int &count)
 {
-	return kvm_getproc2(kd, KERN_PROC_ALL, 0, sizeof (kinfo_proc2), &count);
+	return kvm_getproc2(kd, All, 0, sizeof (kinfo_proc2), &count);
 }
 
 template <>

+ 5 - 4
man1/dtpstree.1

@@ -8,9 +8,9 @@ dtpstree \- display a tree of processes
 .SH DESCRIPTION
 .B dtpstree
 shows running processes as a tree. It is a reimplementation of \fBpstree\fR from
-\fIPSmisc\fR for FreeBSD, NetBSD, and OpenBSD. It also works without \fI/proc\fR
-and will show the full set of processes in a jail even if \fBinit\fR is not
-present.
+\fIPSmisc\fR for FreeBSD, NetBSD, OpenBSD, and other modern BSD variants. It
+also works without \fI/proc\fR and will show the full set of processes in a jail
+even if \fBinit\fR is not present.
 .SH OPTIONS
 .TP
 \fB\-a\fR, \fB\-\-arguments\fR
@@ -80,4 +80,5 @@ See the License for the specific language governing permissions and
 limitations under the License.
 .SH "SEE ALSO"
 .PP
-\fBps\fR(1), \fBkvm\fR(3), \fBkvm_getargv\fR(3), \fBkvm_getprocs\fR(3).
+\fBps\fR(1), \fBkvm\fR(3), \fBkvm_getargv\fR(3) or \fBkvm_getargv2\fR(3),
+\fBkvm_getprocs\fR(3) or \fBkvm_getproc2\fR(3).

Some files were not shown because too many files changed in this diff