From 6c05b35977c9d15da45b4fe6c0c870dbbf51657c Mon Sep 17 00:00:00 2001 From: NIIBE Yutaka Date: Wed, 29 May 2024 15:14:44 +0900 Subject: Cleaner semantics for _gpgrt_process_spawn without a callback. * src/gpg-error.h.in (@define:struct_spawn_cb_arg@): Remove. (gpgrt_spawn_actions_t): New. (@define:spawn_actions_functions@): New. * src/gpgrt-int.h (_gpgrt_spawn_actions_new) (_gpgrt_spawn_actions_release, _gpgrt_spawn_actions_set_envvars) (_gpgrt_spawn_actions_set_redirect): New. [HAVE_W32_SYSTEM] (_gpgrt_spawn_actions_set_inherit_handles): New. [!HAVE_W32_SYSTEM] (_gpgrt_spawn_actions_set_inherit_fds) (_gpgrt_spawn_actions_set_atfork): New. (_gpgrt_process_spawn): Use gpgrt_spawn_actions_t. (_gpgrt_spawn_helper): Remove. * src/mkheader.c: Emit gpgrt_spawn_actions_* definition. * src/spawn-posix.c(_gpgrt_spawn_actions_new) (_gpgrt_spawn_actions_release, _gpgrt_spawn_actions_set_envvars) (_gpgrt_spawn_actions_set_redirect) (_gpgrt_spawn_actions_set_inherit_fds) (_gpgrt_spawn_actions_set_atfork): New. (spawn_detached, _gpgrt_process_spawn): Use gpgrt_spawn_actions_t. (_gpgrt_spawn_helper): Remove. * src/spawn-w32.c: Ditto, with _gpgrt_spawn_actions_set_inherit_handles, but no _gpgrt_spawn_actions_set_atfork. -- GnuPG-bug-id: 6249 Signed-off-by: NIIBE Yutaka --- src/mkheader.c | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) (limited to 'src/mkheader.c') diff --git a/src/mkheader.c b/src/mkheader.c index cb4d574..5005bbc 100644 --- a/src/mkheader.c +++ b/src/mkheader.c @@ -573,27 +573,17 @@ write_special (const char *fname, int lnr, const char *tag) else fputs ("int", stdout); } - else if (!strcmp (tag, "define:struct_spawn_cb_arg")) + else if (!strcmp (tag, "define:spawn_actions_functions")) { if (have_w32_system || have_w64_system) { - fputs ("struct spawn_cb_arg;\n", stdout); - fputs ("#ifdef NEED_STRUCT_SPAWN_CB_ARG\n", stdout); - fputs ("struct spawn_cb_arg {\n", stdout); - fputs (" HANDLE hd[3];\n", stdout); - fputs (" HANDLE *inherit_hds;\n", stdout); - fputs (" BOOL allow_foreground_window;\n", stdout); - fputs (" void *arg;\n", stdout); - fputs ("};\n", stdout); - fputs ("#endif /* NEED_STRUCT_SPAWN_CB_ARG */\n", stdout); + fputs ("void gpgrt_spawn_actions_set_redirect (gpgrt_spawn_actions_t, void *, void *, void *);\n", stdout); + fputs ("void gpgrt_spawn_actions_set_inherit_handles (gpgrt_spawn_actions_t, void **);\n", stdout); } else { - fputs ("struct spawn_cb_arg {\n", stdout); - fputs (" int fds[3];\n", stdout); - fputs (" int *except_fds;\n", stdout); - fputs (" void *arg;\n", stdout); - fputs ("};\n", stdout); + fputs ("void gpgrt_spawn_actions_set_redirect (gpgrt_spawn_actions_t, int, int, int);\n", stdout); + fputs ("void gpgrt_spawn_actions_set_inherit_fds (gpgrt_spawn_actions_t, const int *);\n", stdout); } } else if (!strcmp (tag, "include:err-sources")) -- cgit v1.2.3