Add pidof - a tool which prints PID of given process name.

This commit is contained in:
Roman Bogorodskiy 2005-05-02 07:48:41 +00:00
parent 52440e5212
commit 9920501c2a
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=134486
5 changed files with 53 additions and 0 deletions

View file

@ -357,6 +357,7 @@
SUBDIR += php4-posix
SUBDIR += php5-posix
SUBDIR += pib
SUBDIR += pidof
SUBDIR += pipemeter
SUBDIR += pkg_cutleaves
SUBDIR += pkg_install

25
sysutils/pidof/Makefile Normal file
View file

@ -0,0 +1,25 @@
# New ports collection makefile for: pidof
# Date created: 2005-05-01
# Whom: Roman Bogorodskiy <novel@FreeBSD.org>
#
# $FreeBSD$
#
PORTNAME= pidof
PORTVERSION= 20050501
CATEGORIES= sysutils
MASTER_SITES= ${MASTER_SITE_LOCAL}
MASTER_SITE_SUBDIR= novel
DISTNAME= ${PORTNAME}
MAINTAINER= novel@FreeBSD.org
COMMENT= A tool which prints PID of given process name
CONFLICTS= psmisc-1*
PLIST_FILES= bin/pidof
do-install:
${INSTALL_PROGRAM} ${WRKSRC}/pidof ${PREFIX}/bin
.include <bsd.port.mk>

2
sysutils/pidof/distinfo Normal file
View file

@ -0,0 +1,2 @@
MD5 (pidof.tar.gz) = 58bcaf9a6e325ef6e5fd175175788e56
SIZE (pidof.tar.gz) = 1769

View file

@ -0,0 +1,22 @@
--- pidof.c.orig Mon May 2 07:26:03 2005
+++ pidof.c Mon May 2 07:40:31 2005
@@ -53,10 +53,19 @@
if ((kd = kvm_open("/dev/null", "/dev/null", "/dev/null", O_RDONLY, "kvm_open")) == NULL)
(void)errx(1, "%s", kvm_geterr(kd));
else {
+#if __FreeBSD__ < 5
+ p = kvm_getprocs(kd, KERN_PROC_ALL, 0, &n_processes);
+#else
p = kvm_getprocs(kd, KERN_PROC_PROC, 0, &n_processes);
+#endif /* __FreeBSD__ < 5 */
for (i = 0; i<n_processes; i++)
+#if __FreeBSD__ < 5
+ if (strncmp(process_name, p[i].kp_proc.p_comm, MAXCOMLEN+1) == 0) {
+ (void)printf("%d ", (int)p[i].kp_proc.p_pid);
+#else
if (strncmp(process_name, p[i].ki_comm, COMMLEN+1) == 0) {
(void)printf("%d ", (int)p[i].ki_pid);
+#endif /* __FreeBSD__ < 5 */
processes_found++;
}

3
sysutils/pidof/pkg-descr Normal file
View file

@ -0,0 +1,3 @@
A tool which prints PID of given process name.
WWW: http://people.freebsd.org/~novel/pidof.html