[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v2 3/4] qsd: Add --daemonize
From: |
Kevin Wolf |
Subject: |
Re: [PATCH v2 3/4] qsd: Add --daemonize |
Date: |
Fri, 4 Mar 2022 10:27:12 +0100 |
Am 03.03.2022 um 17:48 hat Hanna Reitz geschrieben:
> To implement this, we reuse the existing daemonizing functions from the
> system emulator, which mainly do the following:
> - Fork off a child process, and set up a pipe between parent and child
> - The parent process waits until the child sends a status byte over the
> pipe (0 means that the child was set up successfully; anything else
> (including errors or EOF) means that the child was not set up
> successfully), and then exits with an appropriate exit status
> - The child process enters a new session (forking off again), changes
> the umask, and will ignore terminal signals from then on
> - Once set-up is complete, the child will chdir to /, redirect all
> standard I/O streams to /dev/null, and tell the parent that set-up has
> been completed successfully
>
> In contrast to qemu-nbd's --fork implementation, during the set up
> phase, error messages are not piped through the parent process.
> qemu-nbd mainly does this to detect errors, though (while os_daemonize()
> has the child explicitly signal success after set up); because we do not
> redirect stderr after forking, error messages continue to appear on
> whatever the parent's stderr was (until set up is complete).
>
> Signed-off-by: Hanna Reitz <hreitz@redhat.com>
> ---
> docs/tools/qemu-storage-daemon.rst | 7 +++++++
> storage-daemon/qemu-storage-daemon.c | 15 +++++++++++++++
> 2 files changed, 22 insertions(+)
>
> diff --git a/docs/tools/qemu-storage-daemon.rst
> b/docs/tools/qemu-storage-daemon.rst
> index 878e6a5c5c..8b97592663 100644
> --- a/docs/tools/qemu-storage-daemon.rst
> +++ b/docs/tools/qemu-storage-daemon.rst
> @@ -154,6 +154,13 @@ Standard options:
> created but before accepting connections. The daemon has started
> successfully
> when the pid file is written and clients may begin connecting.
>
> +.. option:: --daemonize
> +
> + Daemonize the process. The parent process will exit once startup is
> complete
> + (i.e., after the pid file has been or would have been written) or failure
> + occurs. Its exit code reflects whether the child has started up
> successfully
> + or failed to do so.
> +
> Examples
> --------
> Launch the daemon with QMP monitor socket ``qmp.sock`` so clients can execute
> diff --git a/storage-daemon/qemu-storage-daemon.c
> b/storage-daemon/qemu-storage-daemon.c
> index b798954edb..9f2c3332bf 100644
> --- a/storage-daemon/qemu-storage-daemon.c
> +++ b/storage-daemon/qemu-storage-daemon.c
> @@ -137,6 +137,9 @@ static void help(void)
> "\n"
> " --pidfile <path> write process ID to a file after startup\n"
> "\n"
> +" --daemonize daemonize the process, and have the parent exit\n"
> +" once startup is complete\n"
> +"\n"
So far the long options in the help text are sorted alphabetically. Do
we want to keep this?
Kevin
- [PATCH v2 0/4] qsd: Add --daemonize; and add job quit tests, Hanna Reitz, 2022/03/03
- [PATCH v2 2/4] qsd: Add pre-init argument parsing pass, Hanna Reitz, 2022/03/03
- [PATCH v2 3/4] qsd: Add --daemonize, Hanna Reitz, 2022/03/03
- [PATCH v2 4/4] iotests/185: Add post-READY quit tests, Hanna Reitz, 2022/03/03
- Re: [PATCH v2 0/4] qsd: Add --daemonize; and add job quit tests, Kevin Wolf, 2022/03/04