1
0
mirror of https://git.FreeBSD.org/ports.git synced 2024-11-29 01:13:08 +00:00

Import of psmisc-17.

A port of the Linux pstree, killall and pidof commands.
Does not include the 'fuser' command.

PR:		ports/5970
Submitted by:	rantapaa@uswest.net
This commit is contained in:
Justin M. Seger 1998-12-20 03:55:54 +00:00
parent c9e69a1e3b
commit 2fca8778da
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=15442
8 changed files with 230 additions and 0 deletions

20
sysutils/psmisc/Makefile Normal file
View File

@ -0,0 +1,20 @@
# New ports collection makefile for: psmisc
# Version required: psmisc-17
# Date created: 10 March 1998
# Whom: rantapaa@uswest.net
#
# $Id: Makefile,v 1.2 1998/03/10 21:36:52 rantapaa Exp $
#
DISTNAME= psmisc-17
CATEGORIES= sysutils
MASTER_SITES= ftp://ftp.cdrom.com/pub/NetBSD/packages/distfiles/ \
ftp://ftp.bitcon.no/pub/NetBSD/packages/distfiles/
MAINTAINER= rantapaa@uswest.net
INSTALL_TARGET= install-all
MAN1= pidof.1 pstree.1 killall.1
WRKSRC= ${WRKDIR}/psmisc
.include <bsd.port.mk>

1
sysutils/psmisc/distinfo Normal file
View File

@ -0,0 +1 @@
MD5 (psmisc-17.tar.gz) = d7ee62a4c936360aa2f87b24c86e4092

View File

@ -0,0 +1,68 @@
--- Makefile.orig Mon Jul 28 05:28:00 1997
+++ Makefile Sat Dec 19 22:01:20 1998
@@ -3,18 +3,20 @@
-Wall -Wno-parentheses -Wwrite-strings -Wpointer-arith \
# -Wcast-align -Wconversion -g
LDFLAGS=#-s -N #-Xlinker -qmagic
-REAL_CPP=/lib/cpp
-PROGS=killall pstree fuser
-EBINDIR=/bin # essential binaries
-BINDIR=/usr/bin # not so essential ones
-MANDIR=/usr/man/man1 # all man pages
+REAL_CPP=gcc -E
+PROGS=killall pstree # fuser
+EBINDIR=${PREFIX}/bin # essential binaries
+BINDIR=${PREFIX}/bin # not so essential ones
+MANDIR=${PREFIX}/man/man1 # all man pages
+INSTALL_MAN=${BSD_INSTALL_MAN}
+INSTALL_BIN=${BSD_INSTALL_PROGRAM}
all: $(PROGS)
signames.h: /usr/include/signal.h
- $(REAL_CPP) -dM </usr/include/signal.h | \
+ $(REAL_CPP) -dM /usr/include/signal.h | \
tr -s '\t ' ' ' | sort -n +2 | sed \
- 's:#define SIG\([A-Z]\+[0-9]*\) \([0-9]\+\) *\(\|/\*.*\)$$:{\
+ 's:#define SIG\([A-Z][A-Z]*[0-9]*\) \([0-9][0-9]*\).*$$:{\
\2,"\1" },:p;d' \
> signames.h
@@ -25,27 +27,27 @@
fuser: fuser.o signals.o
killall: killall.o signals.o
+ $(CC) $(CFLAGS) $(LDFLAGS) -o killall killall.o signals.o -ltermcap
pstree: pstree.c comm.h Makefile VERSION
$(CC) $(CFLAGS) $(LDFLAGS) -o pstree pstree.c -ltermcap
+install-all: install install-pidof
+
install: $(PROGS)
# EBINDIR is expected to exist, so we don't try to create it
- install -o 0 -g 0 -m 555 fuser $(EBINDIR)
+# install -o 0 -g 0 -m 555 fuser $(EBINDIR)
[ -d $(BINDIR) ] || install -d -o 0 -g 0 -m 755 $(BINDIR)
- install -o 0 -g 0 -m 555 killall $(BINDIR)
- install -o 0 -g 0 -m 555 pstree $(BINDIR)
+ $(INSTALL_BIN) killall $(BINDIR)
+ $(INSTALL_BIN) pstree $(BINDIR)
[ -d $(MANDIR) ] || install -d -o 0 -g 0 -m 755 $(MANDIR)
- install -o 0 -g 0 -m 444 fuser.1 $(MANDIR)
- install -o 0 -g 0 -m 444 killall.1 $(MANDIR)
- install -o 0 -g 0 -m 444 pstree.1 $(MANDIR)
+# install -o 0 -g 0 -m 444 fuser.1 $(MANDIR)
+ $(INSTALL_MAN) killall.1 $(MANDIR)
+ $(INSTALL_MAN) pstree.1 $(MANDIR)
install-pidof:
- @[ -x `echo $(BINDIR)`/killall ] || { \
- echo "Need `echo $(BINDIR)`/killall to install pidof"; \
- exit 1 }
ln -sf killall `echo $(BINDIR)`/pidof
- install -o 0 -g 0 -m 444 pidof.1 $(MANDIR)
+ $(INSTALL_MAN) pidof.1 $(MANDIR)
clean:
rm -f *.o signames.h

View File

@ -0,0 +1,63 @@
--- killall.c.orig Tue Feb 17 15:05:21 1998
+++ killall.c Sat Dec 19 22:01:20 1998
@@ -12,6 +12,7 @@
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
+#include <sys/param.h>
#include "comm.h"
#include "signals.h"
@@ -50,7 +51,6 @@
struct stat st,sts[MAX_NAMES];
int *name_len;
char path[PATH_MAX+1],comm[COMM_LEN];
- char command_buf[PATH_MAX+1];
char *command;
pid_t *pid_table,pid,self,*pid_killed;
int empty,i,j,okay,length,got_long,error;
@@ -103,33 +103,15 @@
exit(1);
}
for (i = 0; i < pids; i++) {
- sprintf(path,"%s/%d/stat",PROC_BASE,pid_table[i]);
+ sprintf(path,"%s/%d/status",PROC_BASE,pid_table[i]);
if (!(file = fopen(path,"r"))) continue;
empty = 0;
- okay = fscanf(file,"%*d (%[^)]",comm) == 1;
+ okay = fscanf(file,"%s",comm) == 1;
(void) fclose(file);
if (!okay) continue;
got_long = 0;
command = NULL; /* make gcc happy */
length = strlen(comm);
- if (length == COMM_LEN-1) {
- sprintf(path,"%s/%d/cmdline",PROC_BASE,pid_table[i]);
- if (!(file = fopen(path,"r"))) continue;
- okay = fscanf(file,"%s",command_buf) == 1;
- (void) fclose(file);
- if (exact && !okay) {
- if (verbose)
- fprintf(stderr,"skipping partial match %s(%d)\n",comm,
- pid_table[i]);
- continue;
- }
- got_long = okay;
- if (okay) {
- command = strrchr(command_buf,'/');
- if (command) command++;
- else command = command_buf;
- }
- }
for (j = 0; j < names; j++) {
if (!sts[j].st_dev) {
if (length != COMM_LEN-1 || name_len[j] < COMM_LEN-1) {
@@ -139,7 +121,7 @@
strncmp(namelist[j],comm,COMM_LEN-1)) continue;
}
else {
- sprintf(path,"%s/%d/exe",PROC_BASE,pid_table[i]);
+ sprintf(path,"%s/%d/file",PROC_BASE,pid_table[i]);
if (stat(path,&st) < 0) continue;
if (sts[j].st_dev != st.st_dev || sts[j].st_ino != st.st_ino)
continue;

View File

@ -0,0 +1,72 @@
--- pstree.c.orig Tue Aug 26 12:09:05 1997
+++ pstree.c Sat Dec 19 22:01:20 1998
@@ -9,7 +9,6 @@
#include <ctype.h>
#include <unistd.h>
#include <fcntl.h>
-#include <getopt.h>
#include <pwd.h>
#include <dirent.h>
#include <termios.h>
@@ -17,6 +16,7 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
+#include <sys/param.h>
#include "comm.h"
@@ -387,8 +387,7 @@
char path[PATH_MAX+1],comm[COMM_LEN+1];
char *buffer;
pid_t pid,ppid;
- int fd,size;
- int empty,dummy;
+ int empty;
if (!print_args) buffer = NULL;
else if (!(buffer = malloc((size_t) (output_width+1)))) {
@@ -402,31 +401,15 @@
empty = 1;
while (de = readdir(dir))
if (pid = atoi(de->d_name)) {
- sprintf(path,"%s/%d/stat",PROC_BASE,pid);
+ sprintf(path,"%s/%d/status",PROC_BASE,pid);
if (file = fopen(path,"r")) {
empty = 0;
if (fstat(fileno(file),&st) < 0) {
perror(path);
exit(1);
}
- if (fscanf(file,"%d (%[^)]) %c %d",&dummy,comm,(char *) &dummy,
- &ppid) == 4) {
- if (!print_args) add_proc(comm,pid,ppid,st.st_uid,NULL,0);
- else {
- sprintf(path,"%s/%d/cmdline",PROC_BASE,pid);
- if ((fd = open(path,O_RDONLY)) < 0) {
- perror(path);
- exit(1);
- }
- if ((size = read(fd,buffer,(size_t) output_width)) < 0)
- {
- perror(path);
- exit(1);
- }
- (void) close(fd);
- if (size) buffer[size++] = 0;
- add_proc(comm,pid,ppid,st.st_uid,buffer,size);
- }
+ if (fscanf(file,"%s %*d %d",comm,&ppid) == 2) {
+ add_proc(comm,pid,ppid,st.st_uid,NULL,0);
}
(void) fclose(file);
}
@@ -500,7 +483,7 @@
while ((c = getopt(argc,argv,"acGhnpluUV")) != EOF)
switch (c) {
case 'a':
- print_args = 1;
+ /* print_args = 1; */
break;
case 'c':
compact = 0;

View File

@ -0,0 +1 @@
A port of the Linux pstree, killall and pidof commands.

View File

@ -0,0 +1,2 @@
A port of the Linux pstree, killall and pidof commands.
Does not include the 'fuser' command.

View File

@ -0,0 +1,3 @@
bin/killall
bin/pidof
bin/pstree