From aa6873b85b09a3ea292afc7bfd535c382b57d905 Mon Sep 17 00:00:00 2001 From: Jesse Smith Date: Sat, 10 Nov 2018 21:27:11 -0400 Subject: [PATCH] Removed typos from pidof manual page and killall5 page. Closes Debian bugs #815839, #905245 and #890478 Added -f option to pidof program to allow printf style formating. Closes Debian bug #571590 Thanks to Philipp Marek for the patch. --- doc/Changelog | 7 ++++++- man/killall5.8 | 4 ++-- man/pidof.8 | 15 ++++++++++----- src/killall5.c | 28 +++++++++++++++++++--------- 4 files changed, 37 insertions(+), 17 deletions(-) diff --git a/doc/Changelog b/doc/Changelog index 9411f85..05439b4 100644 --- a/doc/Changelog +++ b/doc/Changelog @@ -42,7 +42,12 @@ sysvinit (2.92) unreleased; urgency=low Closes Debian bug #402847. * Updated src/Makefile to make sure we build all the software before attempting to install. - + * Removed typos from pidof manual page and killall5 page. + Closes Debian bugs #815839, #905245 and #890478 + * Added -f option to pidof program to allow printf + style formating. + Closes Debian bug #571590 + Thanks to Philipp Marek for the patch. sysvinit (2.91) world; urgency=low diff --git a/man/killall5.8 b/man/killall5.8 index 24b819f..ac3cc09 100644 --- a/man/killall5.8 +++ b/man/killall5.8 @@ -22,9 +22,9 @@ killall5 -- send a signal to all processes. .B killall5 .RB -signalnumber .RB [ \-o -.IR omitpid[,omitpid..]] +.IR omitpid[,omitpid...]] .RB [ \-o -.IR omitpid[,omitpid..].. ] +.IR omitpid[,omitpid...]... ] .SH DESCRIPTION .B killall5 is the SystemV killall command. It sends a signal to all processes except diff --git a/man/pidof.8 b/man/pidof.8 index b644ca1..a4295b9 100644 --- a/man/pidof.8 +++ b/man/pidof.8 @@ -25,11 +25,13 @@ pidof -- find the process ID of a running program. .RB [ \-n ] .RB [ \-x ] .RB [ \-o -.IR omitpid[,omitpid..] ] +.IR omitpid[,omitpid...] ] .RB [ \-o -.IR omitpid[,omitpid..].. ] +.IR omitpid[,omitpid...]... ] +.RB [ \-f +.IR format ] .B program -.RB [ program.. ] +.RB [ program... ] .SH DESCRIPTION .B Pidof finds the process id's (PIDs) of the named programs. It prints those @@ -53,7 +55,7 @@ Avoid system function call on all binaries which are located on network based file systems like .BR NFS . -Instead of using this option the the variable +Instead of using this option the variable .B PIDOF_NETFS may be set and exported. .IP \-q @@ -66,6 +68,9 @@ shells running the named scripts. Tells \fIpidof\fP to omit processes with that process id. The special pid \fB%PPID\fP can be used to name the parent process of the \fIpidof\fP program, in other words the calling shell or shell script. +.IP "-f \fIformat\fP" +Tells \fIpidof\fP to format the process ids in the given \fIprintf\fP style. +For example \fB" -p%d"\fP is useful for \fIstrace\fP. .SH "EXIT STATUS" .TP .B 0 @@ -80,7 +85,7 @@ the program behaves according to the name under which it is called. When \fIpidof\fP is invoked with a full pathname to the program it should find the pid of, it is reasonably safe. Otherwise it is possible that it returns PIDs of running programs that happen to have the same name -as the program you're after but are actually other programs. Note that +as the program you're after but are actually other programs. Note that the executable name of running processes is calculated with .BR readlink (2), so symbolic links to executables will also match. diff --git a/src/killall5.c b/src/killall5.c index e8a0ccb..27b5778 100644 --- a/src/killall5.c +++ b/src/killall5.c @@ -945,13 +945,14 @@ void usage(void) void pidof_usage(void) { printf("pidof usage: [options] \n\n"); - printf(" -c Return PIDs with the same root directory\n"); - printf(" -h Display this help text\n"); - printf(" -n Avoid using stat system function on network shares\n"); - printf(" -o Omit results with a given PID\n"); - printf(" -q Quiet mode. Do not display output\n"); - printf(" -s Only return one PID\n"); - printf(" -x Return PIDs of shells running scritps with a matchign name\n"); + printf(" -c Return PIDs with the same root directory\n"); + printf(" -h Display this help text\n"); + printf(" -f Display PIDs in a given printf-style format\n"); + printf(" -n Avoid using stat system function on network shares\n"); + printf(" -o Omit results with a given PID\n"); + printf(" -q Quiet mode. Do not display output\n"); + printf(" -s Only return one PID\n"); + printf(" -x Return PIDs of shells running scritps with a matchign name\n"); printf("\n"); } @@ -996,6 +997,7 @@ int main_pidof(int argc, char **argv) int chroot_check = 0; struct stat st; char tmp[512]; + char *format = NULL; omit = (OMIT*)0; nlist = (NFS*)0; @@ -1004,7 +1006,7 @@ int main_pidof(int argc, char **argv) if ((token = getenv("PIDOF_NETFS")) && (strcmp(token,"no") != 0)) flags |= PIDOF_NETFS; - while ((opt = getopt(argc,argv,"qhco:sxn")) != EOF) switch (opt) { + while ((opt = getopt(argc,argv,"qhcof:sxn")) != EOF) switch (opt) { case '?': nsyslog(LOG_ERR,"invalid options on command line!\n"); closelog(); @@ -1015,6 +1017,9 @@ int main_pidof(int argc, char **argv) case 'h': pidof_usage(); exit(0); + case 'f': + format = optarg; + break; case 'o': here = optarg; while ((token = strsep(&here, ",;:"))) { @@ -1111,9 +1116,14 @@ int main_pidof(int argc, char **argv) } if ( ~flags & PIDOF_QUIET ) { - if (!first) + if (format) + printf(format, p->pid); + else + { + if (! first) printf(" "); printf("%d", p->pid); + } } first = 0; }