On 4/18/23 09:25, Richard W.M. Jones wrote:
Commit 6b03ec8ad6 ("common: Move exit-with-parent code from include/ to utils/") was supposed to be a largely neutral refactoring of the --exit-with-parent flag. However I made a mistake in one hunk of that patch:
-#ifdef HAVE_EXIT_WITH_PARENT - if (exit_with_parent) { - if (set_exit_with_parent () == -1) { - perror ("nbdkit: --exit-with-parent"); - exit (EXIT_FAILURE); - } + if (set_exit_with_parent () == -1) { + perror ("nbdkit: --exit-with-parent"); + exit (EXIT_FAILURE); } -#endif
by removing the test for exit_with_parent. The effect is similar to if we always specified --exit-with-parent when nbdkit is running in the foreground.
Somewhat surprisingly this didn't have any noticable effect. That's for a few of reasons: (1) Mostly if you don't fork then you should be using --exit-with-parent (and the bulk of the tests do this). (2) If we do fork into the background then the PR_SET_PDEATHSIG flag is cleared by Linux across the fork. (3) It actually _did_ break Windows because there set_exit_with_parent calls abort, but for unrelated reasons our Windows CI was broken (and never tested running nbdkit.exe).
Fix this with the obvious adjustment.
This broke nbdkit 1.32 and 1.34.
Fixes: commit 6b03ec8ad672e5956b41cbacae9c307e5acd786b --- server/main.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/server/main.c b/server/main.c index c3b9bf384..1df5d69ac 100644 --- a/server/main.c +++ b/server/main.c @@ -574,9 +574,11 @@ main (int argc, char *argv[]) /* Implement --exit-with-parent early in case plugin initialization * takes a long time and the parent exits during that time. */ - if (set_exit_with_parent () == -1) { - perror ("nbdkit: --exit-with-parent"); - exit (EXIT_FAILURE); + if (exit_with_parent) { + if (set_exit_with_parent () == -1) { + perror ("nbdkit: --exit-with-parent"); + exit (EXIT_FAILURE); + } }
/* If the user has mixed up -p/--run/-s/-U/--vsock options, then
Reviewed-by: Laszlo Ersek <lersek@redhat.com>