summaryrefslogtreecommitdiff
path: root/sysutils/psmisc
diff options
context:
space:
mode:
authorfrueauf <frueauf>1998-07-20 10:25:51 +0000
committerfrueauf <frueauf>1998-07-20 10:25:51 +0000
commit86fbc1c9af696356272f73c5361c6f8ab17605a1 (patch)
tree003b05c575e1ce6932d28419096129df4ac71c32 /sysutils/psmisc
parenta1db6ff5b61c15f89c71f62594c8be825213024f (diff)
downloadpkgsrc-86fbc1c9af696356272f73c5361c6f8ab17605a1.tar.gz
Initial addition of psmisc-17, some miscellaneous proc FS tools: killall,
pidof, and pstree. Closes pr 5801 by Ben Harris.
Diffstat (limited to 'sysutils/psmisc')
-rw-r--r--sysutils/psmisc/Makefile14
-rw-r--r--sysutils/psmisc/files/md51
-rw-r--r--sysutils/psmisc/patches/patch-aa61
-rw-r--r--sysutils/psmisc/patches/patch-ab20
-rw-r--r--sysutils/psmisc/patches/patch-ac61
-rw-r--r--sysutils/psmisc/patches/patch-ad123
-rw-r--r--sysutils/psmisc/patches/patch-ae78
-rw-r--r--sysutils/psmisc/patches/patch-af10
-rw-r--r--sysutils/psmisc/pkg/COMMENT1
-rw-r--r--sysutils/psmisc/pkg/DESCR16
-rw-r--r--sysutils/psmisc/pkg/PLIST7
11 files changed, 392 insertions, 0 deletions
diff --git a/sysutils/psmisc/Makefile b/sysutils/psmisc/Makefile
new file mode 100644
index 00000000000..eff326811fb
--- /dev/null
+++ b/sysutils/psmisc/Makefile
@@ -0,0 +1,14 @@
+# $NetBSD: Makefile,v 1.1 1998/07/20 10:25:51 frueauf Exp $
+#
+
+DISTNAME= psmisc-17
+CATEGORIES= sysutils
+MASTER_SITES= ftp://lrcftp.epfl.ch/pub/linux/local/psmisc/ \
+ ${MASTER_SITE_SUNSITE}
+MASTER_SITE_SUBDIR= system/status/ps
+
+MAINTAINER= bjh21@cam.ac.uk
+
+WRKSRC= ${WRKDIR}/psmisc
+
+.include "../../mk/bsd.pkg.mk"
diff --git a/sysutils/psmisc/files/md5 b/sysutils/psmisc/files/md5
new file mode 100644
index 00000000000..864c4a36e72
--- /dev/null
+++ b/sysutils/psmisc/files/md5
@@ -0,0 +1 @@
+MD5 (psmisc-17.tar.gz) = d7ee62a4c936360aa2f87b24c86e4092
diff --git a/sysutils/psmisc/patches/patch-aa b/sysutils/psmisc/patches/patch-aa
new file mode 100644
index 00000000000..52000c74b1a
--- /dev/null
+++ b/sysutils/psmisc/patches/patch-aa
@@ -0,0 +1,61 @@
+--- Makefile.orig Mon Jul 28 10:28:00 1997
++++ Makefile Sun Jul 19 17:35:06 1998
+@@ -3,11 +3,11 @@
+ -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=/usr/bin/cpp
++PROGS=killall pstree #fuser
++EBINDIR=$(PREFIX)/bin # essential binaries
++BINDIR=$(PREFIX)/bin # not so essential ones
++MANDIR=$(PREFIX)/man/man1 # all man pages
+
+ all: $(PROGS)
+
+@@ -18,34 +18,26 @@
+ \2,"\1" },:p;d' \
+ > signames.h
+
+-signals.o: signals.h signals.c signames.h Makefile
++signals.o: signals.h signals.c Makefile
+
+ fuser.o: fuser.c comm.h signals.h Makefile VERSION
+ killall.o: killall.c comm.h signals.h Makefile VERSION
+
+ fuser: fuser.o signals.o
+ killall: killall.o signals.o
++ $(CC) $(LDFLAGS) -o killall killall.o signals.o
+
+ pstree: pstree.c comm.h Makefile VERSION
+ $(CC) $(CFLAGS) $(LDFLAGS) -o pstree pstree.c -ltermcap
+
+ install: $(PROGS)
+ # EBINDIR is expected to exist, so we don't try to create it
+- 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)
+- [ -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-pidof:
+- @[ -x `echo $(BINDIR)`/killall ] || { \
+- echo "Need `echo $(BINDIR)`/killall to install pidof"; \
+- exit 1 }
++ $(BSD_INSTALL_PROGRAM) killall $(BINDIR)
++ $(BSD_INSTALL_PROGRAM) pstree $(BINDIR)
++ $(BSD_INSTALL_MAN) killall.1 $(MANDIR)
++ $(BSD_INSTALL_MAN) pstree.1 $(MANDIR)
+ ln -sf killall `echo $(BINDIR)`/pidof
+- install -o 0 -g 0 -m 444 pidof.1 $(MANDIR)
++ $(BSD_INSTALL_MAN) pidof.1 $(MANDIR)
+
+ clean:
+ rm -f *.o signames.h
diff --git a/sysutils/psmisc/patches/patch-ab b/sysutils/psmisc/patches/patch-ab
new file mode 100644
index 00000000000..70a0e070f95
--- /dev/null
+++ b/sysutils/psmisc/patches/patch-ab
@@ -0,0 +1,20 @@
+--- comm.h.orig Tue Sep 19 15:02:20 1995
++++ comm.h Sat Jul 18 22:40:04 1998
+@@ -6,6 +6,10 @@
+ #ifndef COMM_H
+ #define COMM_H
+
++#include <sys/param.h>
++#ifdef MAXCOMLEN
++#define COMM_LEN MAXCOMLEN
++#else
+ #if 0 /* broken in 1.3.xx */
+ #include <linux/sched.h>
+ #define COMM_LEN sizeof(dummy.comm)
+@@ -14,5 +18,6 @@
+ #define COMM_LEN 16 /* synchronize with size of comm in struct task_struct in
+ /usr/include/linux/sched.h */
+ #endif
++#endif /* MAXCOMLEN */
+
+ #endif
diff --git a/sysutils/psmisc/patches/patch-ac b/sysutils/psmisc/patches/patch-ac
new file mode 100644
index 00000000000..c849c88abb6
--- /dev/null
+++ b/sysutils/psmisc/patches/patch-ac
@@ -0,0 +1,61 @@
+--- killall.c.orig Tue Feb 17 20:05:21 1998
++++ killall.c Sun Jul 19 16:18:26 1998
+@@ -2,6 +2,13 @@
+
+ /* Copyright 1993-1998 Werner Almesberger. See file COPYING for details. */
+
++#if (defined(__unix__) || defined(unix)) && !defined(USG)
++#include <sys/param.h>
++#endif
++
++#if (defined(BSD) && BSD >= 199306)
++#define BSD_44_PROC
++#endif
+
+ #include <stdlib.h>
+ #include <stdio.h>
+@@ -103,20 +110,32 @@
+ exit(1);
+ }
+ for (i = 0; i < pids; i++) {
++#ifdef BSD_44_PROC
++ sprintf(path,"%s/%d/status",PROC_BASE,pid_table[i]);
++#else
+ sprintf(path,"%s/%d/stat",PROC_BASE,pid_table[i]);
++#endif
+ if (!(file = fopen(path,"r"))) continue;
+ empty = 0;
++#ifdef BSD_44_PROC
++ okay = fscanf(file,"%s",comm) == 1;
++#else
+ okay = fscanf(file,"%*d (%[^)]",comm) == 1;
++#endif
+ (void) fclose(file);
+ if (!okay) continue;
+ got_long = 0;
+ command = NULL; /* make gcc happy */
+ length = strlen(comm);
+ if (length == COMM_LEN-1) {
++#ifdef BSD_44_PROC
++ okay = 0;
++#else
+ 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);
++#endif
+ if (exact && !okay) {
+ if (verbose)
+ fprintf(stderr,"skipping partial match %s(%d)\n",comm,
+@@ -139,7 +158,11 @@
+ strncmp(namelist[j],comm,COMM_LEN-1)) continue;
+ }
+ else {
++#ifdef BSD_44_PROC
++ sprintf(path,"%s/%d/file",PROC_BASE,pid_table[i]);
++#else
+ sprintf(path,"%s/%d/exe",PROC_BASE,pid_table[i]);
++#endif
+ if (stat(path,&st) < 0) continue;
+ if (sts[j].st_dev != st.st_dev || sts[j].st_ino != st.st_ino)
+ continue;
diff --git a/sysutils/psmisc/patches/patch-ad b/sysutils/psmisc/patches/patch-ad
new file mode 100644
index 00000000000..7d0013e0a38
--- /dev/null
+++ b/sysutils/psmisc/patches/patch-ad
@@ -0,0 +1,123 @@
+--- pstree.c.orig Tue Aug 26 17:09:05 1997
++++ pstree.c Sun Jul 19 15:20:24 1998
+@@ -2,6 +2,14 @@
+
+ /* Copyright 1993-1996 Werner Almesberger. See file COPYING for details. */
+
++#ifdef __NetBSD__
++#define HAVE_SYS_SYSLIMITS_H
++#define BSD_44_PROC
++#define BSD_TERMCAP
++#else /* Linux */
++#define HAVE_GETOPT_H
++#define ENABLE_PRINT_ARGS
++#endif
+
+ #include <stdlib.h>
+ #include <stdio.h>
+@@ -9,12 +17,17 @@
+ #include <ctype.h>
+ #include <unistd.h>
+ #include <fcntl.h>
++#ifdef HAVE_GETOPT_H
+ #include <getopt.h>
++#endif
+ #include <pwd.h>
+ #include <dirent.h>
+ #include <termios.h>
+ #include <termcap.h>
+ #include <sys/types.h>
++#ifdef HAVE_SYS_SYSLIMITS_H
++#include <sys/syslimits.h>
++#endif
+ #include <sys/stat.h>
+ #include <sys/ioctl.h>
+
+@@ -251,7 +264,10 @@
+ CHILD *walk,*next,**scan;
+ const struct passwd *pw;
+ int lvl,i,add,offset,len,swapped,info,count,comm_len,first;
+ const char *tmp,*here;
++#ifdef BSD_TERMCAP
++ char tbuf[1024], *tbufptr;
++#endif
+ char comm_tmp[5];
+
+ if (!current) return;
+@@ -270,7 +286,12 @@
+ add = out_int(rep)+2;
+ out_string("*[");
+ }
++#ifdef BSD_TERMCAP
++ tbufptr = tbuf;
++ if (current->highlight && (tmp = tgetstr("md",&tbufptr))) tputs(tmp,1,putchar);
++#else
+ if (current->highlight && (tmp = tgetstr("md",NULL))) tputs(tmp,1,putchar);
++#endif
+ if (swapped = print_args && current->argc < 0) out_char('(');
+ comm_len = 0;
+ for (here = current->comm; *here; here++)
+@@ -297,7 +318,12 @@
+ else (void) out_int(current->uid);
+ }
+ if (info || swapped) out_char(')');
++#ifdef BSD_TERMCAP
++ tbufptr = tbuf;
++ if (current->highlight && (tmp = tgetstr("me",&tbufptr))) tputs(tmp,1,putchar);
++#else
+ if (current->highlight && (tmp = tgetstr("me",NULL))) tputs(tmp,1,putchar);
++#endif
+ if (print_args) {
+ for (i = 0; i < current->argc; i++) {
+ out_char(' ');
+@@ -387,8 +413,10 @@
+ char path[PATH_MAX+1],comm[COMM_LEN+1];
+ char *buffer;
+ pid_t pid,ppid;
++#ifndef BSD_44_PROC
+ int fd,size;
+- int empty,dummy;
++#endif
++ int empty;
+
+ if (!print_args) buffer = NULL;
+ else if (!(buffer = malloc((size_t) (output_width+1)))) {
+@@ -402,17 +430,28 @@
+ empty = 1;
+ while (de = readdir(dir))
+ if (pid = atoi(de->d_name)) {
++#ifdef BSD_44_PROC
++ sprintf(path,"%s/%d/status",PROC_BASE,pid);
++#else
+ sprintf(path,"%s/%d/stat",PROC_BASE,pid);
++#endif
+ 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) {
++#ifdef BSD_44_PROC
++ if (fscanf(file, "%s %*d %d", comm, &ppid) == 2) {
++#else
++ if (fscanf(file,"%*d (%[^)]) %*c %d",comm,&ppid) == 2) {
++#endif
+ if (!print_args) add_proc(comm,pid,ppid,st.st_uid,NULL,0);
+ else {
++#ifdef BSD_44_PROC
++ /* NetBSD 1.3 /proc doesn't seem to do command-lines */
++ add_proc(comm,pid,ppid,st.st_uid,buffer,0);
++#else
+ sprintf(path,"%s/%d/cmdline",PROC_BASE,pid);
+ if ((fd = open(path,O_RDONLY)) < 0) {
+ perror(path);
+@@ -426,6 +465,7 @@
+ (void) close(fd);
+ if (size) buffer[size++] = 0;
+ add_proc(comm,pid,ppid,st.st_uid,buffer,size);
++#endif
+ }
+ }
+ (void) fclose(file);
diff --git a/sysutils/psmisc/patches/patch-ae b/sysutils/psmisc/patches/patch-ae
new file mode 100644
index 00000000000..c4aac46c434
--- /dev/null
+++ b/sysutils/psmisc/patches/patch-ae
@@ -0,0 +1,78 @@
+--- signals.c.orig Tue Mar 28 21:32:06 1995
++++ signals.c Sun Jul 19 14:07:51 1998
+@@ -2,14 +2,18 @@
+
+ /* Copyright 1993-1995 Werner Almesberger. See file COPYING for details. */
+
+-
++#include <signal.h>
+ #include <stdlib.h>
+ #include <stdio.h>
+ #include <string.h>
+ #include <ctype.h>
+ #include "signals.h"
+
++#ifdef __NetBSD__
++#define HAVE_SYS_SIGNAME
++#endif
+
++#ifndef HAVE_SYS_SIGNAME
+ typedef struct {
+ int number;
+ const char *name;
+@@ -19,9 +23,25 @@
+ static SIGNAME signals[] = {
+ #include "signames.h"
+ { 0,NULL }};
+-
++#endif
+
+ void list_signals(void)
++#ifdef HAVE_SYS_SIGNAME
++{
++ int i, col;
++
++ col = 0;
++ for (i = 1; i < NSIG; i++) {
++ if (col+strlen(sys_signame[i])+1 > 80) {
++ putchar('\n');
++ col = 0;
++ }
++ printf("%s%s",col ? " " : "",sys_signame[i]);
++ col += strlen(sys_signame[i])+1;
++ }
++ putchar('\n');
++}
++#else
+ {
+ SIGNAME *walk;
+ int col;
+@@ -37,9 +57,22 @@
+ }
+ putchar('\n');
+ }
+-
++#endif
+
+ int get_signal(char *name,const char *cmd)
++#ifdef HAVE_SYS_SIGNAME
++{
++ int i;
++
++ if (isdigit(*name))
++ return atoi(name);
++ for (i = 1; i < NSIG; i++)
++ if (!strcmp(sys_signame[i],name)) break;
++ if (i < NSIG) return i;
++ fprintf(stderr,"%s: unknown signal; %s -l lists signals.\n",name,cmd);
++ exit(1);
++}
++#else
+ {
+ SIGNAME *walk;
+
+@@ -51,3 +84,4 @@
+ fprintf(stderr,"%s: unknown signal; %s -l lists signals.\n",name,cmd);
+ exit(1);
+ }
++#endif
diff --git a/sysutils/psmisc/patches/patch-af b/sysutils/psmisc/patches/patch-af
new file mode 100644
index 00000000000..5ca5fecef23
--- /dev/null
+++ b/sysutils/psmisc/patches/patch-af
@@ -0,0 +1,10 @@
+--- pstree.1.orig Sun Apr 7 15:57:44 1996
++++ pstree.1 Sun Jul 19 23:51:52 1998
+@@ -78,4 +78,7 @@
+ Werner Almesberger <werner.almesberger@lrc.di.epfl.ch>
+ .SH "SEE ALSO"
+ ps(1), top(1)
++.SH BUGS
++The \fB\-a\fP option does nothing of any use under NetBSD due to deficiencies
++in the BSD version of /proc.
+ .\"{{{}}}
diff --git a/sysutils/psmisc/pkg/COMMENT b/sysutils/psmisc/pkg/COMMENT
new file mode 100644
index 00000000000..59b23613b85
--- /dev/null
+++ b/sysutils/psmisc/pkg/COMMENT
@@ -0,0 +1 @@
+miscellaneous proc FS tools: killall, pidof, and pstree
diff --git a/sysutils/psmisc/pkg/DESCR b/sysutils/psmisc/pkg/DESCR
new file mode 100644
index 00000000000..5161cc2aa79
--- /dev/null
+++ b/sysutils/psmisc/pkg/DESCR
@@ -0,0 +1,16 @@
+psmisc, version 17
+==================
+
+This package contains three little utilities that use the proc FS:
+
+ killall kills processes by name, e.g. killall -HUP named
+ pidof like killall, buts lists PIDs instead of killing processes
+ pstree shows the currently running processes as a tree
+
+The Linux version includes "fuser" for listing processes' open files,
+but NetBSD's procfs doesn't have the facilities for this (use the lsof
+package instead).
+
+- Werner Almesberger <werner.almesberger@lrc.di.epfl.ch>
+
+ported to NetBSD by Ben Harris <bjh@mail.dotcom.fr>
diff --git a/sysutils/psmisc/pkg/PLIST b/sysutils/psmisc/pkg/PLIST
new file mode 100644
index 00000000000..4d93cf0e16e
--- /dev/null
+++ b/sysutils/psmisc/pkg/PLIST
@@ -0,0 +1,7 @@
+@comment $NetBSD: PLIST,v 1.1 1998/07/20 10:25:54 frueauf Exp $
+bin/killall
+bin/pidof
+bin/pstree
+man/man1/killall.1
+man/man1/pidof.1
+man/man1/pstree.1