]> granicus.if.org Git - procps-ng/commitdiff
pidof: Fix separator option
authorCraig Small <csmall@dropbear.xyz>
Sat, 21 Sep 2019 06:17:05 +0000 (16:17 +1000)
committerCraig Small <csmall@dropbear.xyz>
Sat, 21 Sep 2019 06:20:41 +0000 (16:20 +1000)
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 73492b182dc60c1605d1b0d62de651fad97807af
    procps-ng/procps#141

pidof.1
pidof.c

diff --git a/pidof.1 b/pidof.1
index 1368704c0b3bc4feb391e927675e77624aa3643b..8ef4abfbb197c7a7e507b2979e3f8248194083e0 100644 (file)
--- a/pidof.1
+++ b/pidof.1
@@ -15,7 +15,7 @@
 .\" along with this program; if not, write to the Free Software
 .\" 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
 pidof -- find the process ID of a running program.
 .SH SYNOPSIS
@@ -52,6 +52,8 @@ program, in other words the calling shell or shell script.
 .IP "-S \fIseparator\fP"
 Use \fIseparator\fP as a separator put between pids. Used only when
 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"
 .TP
 .B 0
diff --git a/pidof.c b/pidof.c
index c4288115dcd54e4ff1baa10990e674bf06e34b42..cff91260a5d2ea5675fc8df74f0cc0193614a502 100644 (file)
--- a/pidof.c
+++ b/pidof.c
@@ -295,13 +295,13 @@ int main (int argc, char **argv)
        int first_pid = 1;
 
        const char *separator = " ";
-       const char *opts = "scnxmo:S:?Vh";
+       const char *opts = "scdnxmo:S:?Vh";
 
        static const struct option longopts[] = {
                {"check-root", no_argument, NULL, 'c'},
                {"single-shot", no_argument, NULL, 's'},
                {"omit-pid", required_argument, NULL, 'o'},
-               {"separator", required_argument, NULL, 's'},
+               {"separator", required_argument, NULL, 'S'},
                {"help", no_argument, NULL, 'h'},
                {"version", no_argument, NULL, 'V'},
                {NULL, 0, NULL, 0}
@@ -334,6 +334,7 @@ int main (int argc, char **argv)
                                pidof_root = pid_link(getpid(), "root");
                        }
                        break;
+               case 'd': /* sysv pidof uses this for S */
                case 'S':
                        separator = optarg;
                        break;