Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 23 Mar 2012 20:09:21 +0000 (UTC)
From:      Mikolaj Golub <trociny@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r233390 - head/usr.bin/procstat
Message-ID:  <201203232009.q2NK9LJl092131@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: trociny
Date: Fri Mar 23 20:09:21 2012
New Revision: 233390
URL: http://svn.freebsd.org/changeset/base/233390

Log:
  When displaying binary information show also osreldate.
  
  Suggested by:	kib
  MFC after:	2 weeks

Modified:
  head/usr.bin/procstat/procstat.1
  head/usr.bin/procstat/procstat_bin.c

Modified: head/usr.bin/procstat/procstat.1
==============================================================================
--- head/usr.bin/procstat/procstat.1	Fri Mar 23 20:05:41 2012	(r233389)
+++ head/usr.bin/procstat/procstat.1	Fri Mar 23 20:09:21 2012	(r233390)
@@ -25,7 +25,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd February 29, 2012
+.Dd March 23, 2012
 .Dt PROCSTAT 1
 .Os
 .Sh NAME
@@ -110,6 +110,8 @@ Display the process ID, command, and pat
 process ID
 .It COMM
 command
+.It OSREL
+osreldate for process binary
 .It PATH
 path to process binary (if available)
 .El

Modified: head/usr.bin/procstat/procstat_bin.c
==============================================================================
--- head/usr.bin/procstat/procstat_bin.c	Fri Mar 23 20:05:41 2012	(r233389)
+++ head/usr.bin/procstat/procstat_bin.c	Fri Mar 23 20:09:21 2012	(r233390)
@@ -43,11 +43,11 @@ void
 procstat_bin(struct kinfo_proc *kipp)
 {
 	char pathname[PATH_MAX];
-	int error, name[4];
+	int error, osrel, name[4];
 	size_t len;
 
 	if (!hflag)
-		printf("%5s %-16s %-53s\n", "PID", "COMM", "PATH");
+		printf("%5s %-16s %8s %s\n", "PID", "COMM", "OSREL", "PATH");
 
 	name[0] = CTL_KERN;
 	name[1] = KERN_PROC;
@@ -65,7 +65,19 @@ procstat_bin(struct kinfo_proc *kipp)
 	if (len == 0 || strlen(pathname) == 0)
 		strcpy(pathname, "-");
 
+	name[2] = KERN_PROC_OSREL;
+
+	len = sizeof(osrel);
+	error = sysctl(name, 4, &osrel, &len, NULL, 0);
+	if (error < 0 && errno != ESRCH) {
+		warn("sysctl: kern.proc.osrel: %d", kipp->ki_pid);
+		return;
+	}
+	if (error < 0)
+		return;
+
 	printf("%5d ", kipp->ki_pid);
 	printf("%-16s ", kipp->ki_comm);
+	printf("%8d ", osrel);
 	printf("%s\n", pathname);
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201203232009.q2NK9LJl092131>