X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=procps%2Fpidof.c;h=98d7949f825f56184f833025722a5e1f65edbd8d;hb=123fdda0a4a838e61c6a7d15c69d3b438136aee0;hp=e102a31c667b8c40c7d4d89248a67599a8c2cd74;hpb=5bc8c005a8e15c43285bc595a8d404de67a482ac;p=oweals%2Fbusybox.git diff --git a/procps/pidof.c b/procps/pidof.c index e102a31c6..98d7949f8 100644 --- a/procps/pidof.c +++ b/procps/pidof.c @@ -6,11 +6,41 @@ * * Licensed under GPLv2, see file LICENSE in this source tree. */ +//config:config PIDOF +//config: bool "pidof (6.6 kb)" +//config: default y +//config: help +//config: Pidof finds the process id's (pids) of the named programs. It prints +//config: those id's on the standard output. +//config: +//config:config FEATURE_PIDOF_SINGLE +//config: bool "Enable single shot (-s)" +//config: default y +//config: depends on PIDOF +//config: help +//config: Support '-s' for returning only the first pid found. +//config: +//config:config FEATURE_PIDOF_OMIT +//config: bool "Enable omitting pids (-o PID)" +//config: default y +//config: depends on PIDOF +//config: help +//config: Support '-o PID' for omitting the given pid(s) in output. +//config: The special pid %PPID can be used to name the parent process +//config: of the pidof, in other words the calling shell or shell script. + +//applet:IF_PIDOF(APPLET(pidof, BB_DIR_BIN, BB_SUID_DROP)) +/* can't be noexec: can find _itself_ under wrong name, since after fork only, + * /proc/PID/cmdline and comm are wrong! Can fix comm (prctl(PR_SET_NAME)), + * but cmdline? + */ + +//kbuild:lib-$(CONFIG_PIDOF) += pidof.o //usage:#if (ENABLE_FEATURE_PIDOF_SINGLE || ENABLE_FEATURE_PIDOF_OMIT) //usage:#define pidof_trivial_usage //usage: "[OPTIONS] [NAME]..." -//usage:#define USAGE_PIDOF "\n\nOptions:" +//usage:#define USAGE_PIDOF "\n" //usage:#else //usage:#define pidof_trivial_usage //usage: "[NAME]..." @@ -51,13 +81,12 @@ int pidof_main(int argc UNUSED_PARAM, char **argv) unsigned opt; #if ENABLE_FEATURE_PIDOF_OMIT llist_t *omits = NULL; /* list of pids to omit */ - opt_complementary = "o::"; #endif /* do unconditional option parsing */ opt = getopt32(argv, "" IF_FEATURE_PIDOF_SINGLE ("s") - IF_FEATURE_PIDOF_OMIT("o:", &omits)); + IF_FEATURE_PIDOF_OMIT("o:*", &omits)); #if ENABLE_FEATURE_PIDOF_OMIT /* fill omit list. */