Removed typos from pidof manual page and killall5 page.

Closes Debian bugs #815839, #905245 and #890478

Added -f <format> option to pidof program to allow printf
style formating.
Closes Debian bug #571590
Thanks to Philipp Marek for the patch.
This commit is contained in:
Jesse Smith 2018-11-10 21:27:11 -04:00
parent 2ece2c0364
commit aa6873b85b
4 changed files with 37 additions and 17 deletions

View File

@ -42,7 +42,12 @@ sysvinit (2.92) unreleased; urgency=low
Closes Debian bug #402847. Closes Debian bug #402847.
* Updated src/Makefile to make sure we build all the software before * Updated src/Makefile to make sure we build all the software before
attempting to install. attempting to install.
* Removed typos from pidof manual page and killall5 page.
Closes Debian bugs #815839, #905245 and #890478
* Added -f <format> 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 sysvinit (2.91) world; urgency=low

View File

@ -22,9 +22,9 @@ killall5 -- send a signal to all processes.
.B killall5 .B killall5
.RB -signalnumber .RB -signalnumber
.RB [ \-o .RB [ \-o
.IR omitpid[,omitpid..]] .IR omitpid[,omitpid...]]
.RB [ \-o .RB [ \-o
.IR omitpid[,omitpid..].. ] .IR omitpid[,omitpid...]... ]
.SH DESCRIPTION .SH DESCRIPTION
.B killall5 .B killall5
is the SystemV killall command. It sends a signal to all processes except is the SystemV killall command. It sends a signal to all processes except

View File

@ -25,11 +25,13 @@ pidof -- find the process ID of a running program.
.RB [ \-n ] .RB [ \-n ]
.RB [ \-x ] .RB [ \-x ]
.RB [ \-o .RB [ \-o
.IR omitpid[,omitpid..] ] .IR omitpid[,omitpid...] ]
.RB [ \-o .RB [ \-o
.IR omitpid[,omitpid..].. ] .IR omitpid[,omitpid...]... ]
.RB [ \-f
.IR format ]
.B program .B program
.RB [ program.. ] .RB [ program... ]
.SH DESCRIPTION .SH DESCRIPTION
.B Pidof .B Pidof
finds the process id's (PIDs) of the named programs. It prints those 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 system function call on all binaries which are located on network
based file systems like based file systems like
.BR NFS . .BR NFS .
Instead of using this option the the variable Instead of using this option the variable
.B PIDOF_NETFS .B PIDOF_NETFS
may be set and exported. may be set and exported.
.IP \-q .IP \-q
@ -66,6 +68,9 @@ shells running the named scripts.
Tells \fIpidof\fP to omit processes with that process id. The special 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 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. 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" .SH "EXIT STATUS"
.TP .TP
.B 0 .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 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 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 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 that the executable name of running processes is calculated with
.BR readlink (2), .BR readlink (2),
so symbolic links to executables will also match. so symbolic links to executables will also match.

View File

@ -945,13 +945,14 @@ void usage(void)
void pidof_usage(void) void pidof_usage(void)
{ {
printf("pidof usage: [options] <program-name>\n\n"); printf("pidof usage: [options] <program-name>\n\n");
printf(" -c Return PIDs with the same root directory\n"); printf(" -c Return PIDs with the same root directory\n");
printf(" -h Display this help text\n"); printf(" -h Display this help text\n");
printf(" -n Avoid using stat system function on network shares\n"); printf(" -f <format> Display PIDs in a given printf-style format\n");
printf(" -o <pid> Omit results with a given PID\n"); printf(" -n Avoid using stat system function on network shares\n");
printf(" -q Quiet mode. Do not display output\n"); printf(" -o <pid> Omit results with a given PID\n");
printf(" -s Only return one PID\n"); printf(" -q Quiet mode. Do not display output\n");
printf(" -x Return PIDs of shells running scritps with a matchign name\n"); printf(" -s Only return one PID\n");
printf(" -x Return PIDs of shells running scritps with a matchign name\n");
printf("\n"); printf("\n");
} }
@ -996,6 +997,7 @@ int main_pidof(int argc, char **argv)
int chroot_check = 0; int chroot_check = 0;
struct stat st; struct stat st;
char tmp[512]; char tmp[512];
char *format = NULL;
omit = (OMIT*)0; omit = (OMIT*)0;
nlist = (NFS*)0; nlist = (NFS*)0;
@ -1004,7 +1006,7 @@ int main_pidof(int argc, char **argv)
if ((token = getenv("PIDOF_NETFS")) && (strcmp(token,"no") != 0)) if ((token = getenv("PIDOF_NETFS")) && (strcmp(token,"no") != 0))
flags |= PIDOF_NETFS; flags |= PIDOF_NETFS;
while ((opt = getopt(argc,argv,"qhco:sxn")) != EOF) switch (opt) { while ((opt = getopt(argc,argv,"qhcof:sxn")) != EOF) switch (opt) {
case '?': case '?':
nsyslog(LOG_ERR,"invalid options on command line!\n"); nsyslog(LOG_ERR,"invalid options on command line!\n");
closelog(); closelog();
@ -1015,6 +1017,9 @@ int main_pidof(int argc, char **argv)
case 'h': case 'h':
pidof_usage(); pidof_usage();
exit(0); exit(0);
case 'f':
format = optarg;
break;
case 'o': case 'o':
here = optarg; here = optarg;
while ((token = strsep(&here, ",;:"))) { while ((token = strsep(&here, ",;:"))) {
@ -1111,9 +1116,14 @@ int main_pidof(int argc, char **argv)
} }
if ( ~flags & PIDOF_QUIET ) { if ( ~flags & PIDOF_QUIET ) {
if (!first) if (format)
printf(format, p->pid);
else
{
if (! first)
printf(" "); printf(" ");
printf("%d", p->pid); printf("%d", p->pid);
}
} }
first = 0; first = 0;
} }