How to redirect the daemon output to pipe with BusyBox’s start-stop-daemon?
In my development environment which is an Ubuntu 20.04, the
start-stop-daemon tool has the
-C --no-close option to prevent closing any file descriptor in use. Using that option I can redirect the output of any program to a pipe as below.
start-stop-daemon --name MyProgram -C -S -b -x "<PATH_TO_APP>/app.elf" > "output.fifo"
Do not close any file descriptor when forcing the daemon
into the background (since version 1.16.5). Used for
debugging purposes to see the process output, or to
redirect file descriptors to log the process output.
Only relevant when using –background.
However, the BusyBox version of the
start-stop-daemon which I utilize on my execution environment doesn’t have that option. See the
--help page below.
Usage: start-stop-daemon [OPTIONS] [-S|-K] ... [-- ARGS...] Search for matching processes, and then -K: stop all matching processes -S: start a process unless a matching process is found Process matching: -u USERNAME|UID Match only this user's processes -n NAME Match processes with NAME in comm field in /proc/PID/stat -x EXECUTABLE Match processes with this command in /proc/PID/cmdline -p FILE Match a process with PID from FILE All specified conditions must match -S only: -x EXECUTABLE Program to run -a NAME Zeroth argument -b Background -N N Change nice level -c USER[:[GRP]] Change user/group -m Write PID to pidfile specified by -p -K only: -s SIG Signal to send -t Match only, exit with 0 if found Other: -o Exit with status 0 if nothing is done -v Verbose -q Quiet
So, is there a way of redirecting the output while using the daemon tool?
Read more here: Source link