pidof: Fix separator option

Short separator option used 's' instead of 'S' which
meant it pidof would use the single-shot option when you
meant separator.

Added alias for -S using -d to give some sysvinit pidof
compatibility.

References:
    commit 73492b182d
    procps-ng/procps#141
This commit is contained in:
Craig Small 2019-09-21 16:17:05 +10:00
parent 52f112d255
commit 012db8222e
2 changed files with 6 additions and 3 deletions

View File

@ -15,7 +15,7 @@
.\" along with this program; if not, write to the Free Software .\" along with this program; if not, write to the Free Software
.\" Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA .\" Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
.\" .\"
.TH PIDOF 1 "2018-03-03" "" "User Commands" .TH PIDOF 1 "2019-09-21" "" "User Commands"
.SH NAME .SH NAME
pidof -- find the process ID of a running program. pidof -- find the process ID of a running program.
.SH SYNOPSIS .SH SYNOPSIS
@ -52,6 +52,8 @@ program, in other words the calling shell or shell script.
.IP "-S \fIseparator\fP" .IP "-S \fIseparator\fP"
Use \fIseparator\fP as a separator put between pids. Used only when Use \fIseparator\fP as a separator put between pids. Used only when
more than one pids are printed for the program. more than one pids are printed for the program.
The \fI\-d\fR option is an alias for this option for sysvinit pidof
compatibility.
.SH "EXIT STATUS" .SH "EXIT STATUS"
.TP .TP
.B 0 .B 0

View File

@ -295,13 +295,13 @@ int main (int argc, char **argv)
int first_pid = 1; int first_pid = 1;
const char *separator = " "; const char *separator = " ";
const char *opts = "scnxmo:S:?Vh"; const char *opts = "scdnxmo:S:?Vh";
static const struct option longopts[] = { static const struct option longopts[] = {
{"check-root", no_argument, NULL, 'c'}, {"check-root", no_argument, NULL, 'c'},
{"single-shot", no_argument, NULL, 's'}, {"single-shot", no_argument, NULL, 's'},
{"omit-pid", required_argument, NULL, 'o'}, {"omit-pid", required_argument, NULL, 'o'},
{"separator", required_argument, NULL, 's'}, {"separator", required_argument, NULL, 'S'},
{"help", no_argument, NULL, 'h'}, {"help", no_argument, NULL, 'h'},
{"version", no_argument, NULL, 'V'}, {"version", no_argument, NULL, 'V'},
{NULL, 0, NULL, 0} {NULL, 0, NULL, 0}
@ -334,6 +334,7 @@ int main (int argc, char **argv)
pidof_root = pid_link(getpid(), "root"); pidof_root = pid_link(getpid(), "root");
} }
break; break;
case 'd': /* sysv pidof uses this for S */
case 'S': case 'S':
separator = optarg; separator = optarg;
break; break;