+/*
+This is how it is supposed to work:
+
+start-stop-daemon [OPTIONS] [--start|--stop] [[--] arguments...]
+
+One (only) of these must be given:
+ -S,--start Start
+ -K,--stop Stop
+
+Search for matching processes.
+If --stop is given, stop all matching processes (by sending a signal).
+If --start is given, start a new process unless a matching process was found.
+
+Options controlling process matching
+(if multiple conditions are specified, all must match):
+ -u,--user USERNAME|UID Only consider this user's processes
+ -n,--name PROCESS_NAME Look for processes by matching PROCESS_NAME
+ with comm field in /proc/$PID/stat.
+ Only basename is compared:
+ "ntpd" == "./ntpd" == "/path/to/ntpd".
+[TODO: can PROCESS_NAME be a full pathname? Should we require full match then
+with /proc/$PID/exe or argv[0] (comm can't be matched, it never contains path)]
+ -x,--exec EXECUTABLE Look for processes that were started with this
+ command in /proc/$PID/exe and /proc/$PID/cmdline
+ (/proc/$PID/cmdline is a bbox extension)
+ Unlike -n, we match against the full path:
+ "ntpd" != "./ntpd" != "/path/to/ntpd"
+ -p,--pidfile PID_FILE Look for processes with PID from this file
+
+Options which are valid for --start only:
+ -x,--exec EXECUTABLE Program to run (1st arg of execvp). Mandatory.
+ -a,--startas NAME argv[0] (defaults to EXECUTABLE)
+ -b,--background Put process into background
+ -N,--nicelevel N Add N to process' nice level
+ -c,--chuid USER[:[GRP]] Change to specified user [and group]
+ -m,--make-pidfile Write PID to the pidfile
+ (both -m and -p must be given!)
+
+Options which are valid for --stop only:
+ -s,--signal SIG Signal to send (default:TERM)
+ -t,--test Exit with status 0 if process is found
+ (we don't actually start or stop daemons)
+
+Misc options:
+ -o,--oknodo Exit with status 0 if nothing is done
+ -q,--quiet Quiet
+ -v,--verbose Verbose
+*/
+//config:config START_STOP_DAEMON
+//config: bool "start-stop-daemon (12 kb)"
+//config: default y
+//config: help
+//config: start-stop-daemon is used to control the creation and
+//config: termination of system-level processes, usually the ones
+//config: started during the startup of the system.
+//config:
+//config:config FEATURE_START_STOP_DAEMON_LONG_OPTIONS
+//config: bool "Enable long options"
+//config: default y
+//config: depends on START_STOP_DAEMON && LONG_OPTS
+//config:
+//config:config FEATURE_START_STOP_DAEMON_FANCY
+//config: bool "Support additional arguments"
+//config: default y
+//config: depends on START_STOP_DAEMON
+//config: help
+//config: -o|--oknodo ignored since we exit with 0 anyway
+//config: -v|--verbose
+//config: -N|--nicelevel N
+
+//applet:IF_START_STOP_DAEMON(APPLET_ODDNAME(start-stop-daemon, start_stop_daemon, BB_DIR_SBIN, BB_SUID_DROP, start_stop_daemon))
+/* not NOEXEC: uses bb_common_bufsiz1 */
+
+//kbuild:lib-$(CONFIG_START_STOP_DAEMON) += start_stop_daemon.o
+
+//usage:#define start_stop_daemon_trivial_usage
+//usage: "[OPTIONS] [-S|-K] ... [-- ARGS...]"
+//usage:#define start_stop_daemon_full_usage "\n\n"
+//usage: "Search for matching processes, and then\n"
+//usage: "-K: stop all matching processes\n"
+//usage: "-S: start a process unless a matching process is found\n"
+//usage: "\nProcess matching:"
+//usage: "\n -u USERNAME|UID Match only this user's processes"
+//usage: "\n -n NAME Match processes with NAME"
+//usage: "\n in comm field in /proc/PID/stat"
+//usage: "\n -x EXECUTABLE Match processes with this command"
+//usage: "\n command in /proc/PID/cmdline"
+//usage: "\n -p FILE Match a process with PID from FILE"
+//usage: "\n All specified conditions must match"
+//usage: "\n-S only:"
+//usage: "\n -x EXECUTABLE Program to run"
+//usage: "\n -a NAME Zeroth argument"
+//usage: "\n -b Background"
+//usage: IF_FEATURE_START_STOP_DAEMON_FANCY(
+//usage: "\n -N N Change nice level"
+//usage: )
+//usage: "\n -c USER[:[GRP]] Change user/group"
+//usage: "\n -m Write PID to pidfile specified by -p"
+//usage: "\n-K only:"
+//usage: "\n -s SIG Signal to send"
+//usage: "\n -t Match only, exit with 0 if found"
+//usage: "\nOther:"
+//usage: IF_FEATURE_START_STOP_DAEMON_FANCY(
+//usage: "\n -o Exit with status 0 if nothing is done"
+//usage: "\n -v Verbose"
+//usage: )
+//usage: "\n -q Quiet"
+
+#include <sys/resource.h>
+
+/* Override ENABLE_FEATURE_PIDFILE */
+#define WANT_PIDFILE 1
+#include "libbb.h"
+#include "common_bufsiz.h"
+
+struct pid_list {