aboutsummaryrefslogtreecommitdiffstats
path: root/common/exechelp.h
diff options
context:
space:
mode:
authorNIIBE Yutaka <[email protected]>2024-05-31 06:36:39 +0000
committerNIIBE Yutaka <[email protected]>2024-05-31 06:36:39 +0000
commitfc3fde1bdeb260c92b0a3ea7489536129e9a8a93 (patch)
treed5eb2a841f582211f48dc155f4fd079ea4ead597 /common/exechelp.h
parentcommon: Fix process termination check at release. (diff)
downloadgnupg-fc3fde1bdeb260c92b0a3ea7489536129e9a8a93.tar.gz
gnupg-fc3fde1bdeb260c92b0a3ea7489536129e9a8a93.zip
spawn: Remove spawn callback, introduce gnupg_spawn_actions.
* common/exechelp-posix.c (call_spawn_cb): Remove. (gnupg_spawn_actions_new, gnupg_spawn_actions_release) (gnupg_spawn_actions_set_environ, gnupg_spawn_actions_set_atfork) (gnupg_spawn_actions_set_redirect) (gnupg_spawn_actions_set_inherit_fds): New. (my_exec, spawn_detached): Use spawn actions. (gnupg_spawn_helper): Remove. (gnupg_process_spawn): Remove callback, introduce gnupg_spawn_actions. * common/exechelp-w32.c: Ditto. * common/exechelp.h: Ditto. * agent/genkey.c (do_check_passphrase_pattern): Follow the change of gnupg_process_spawn API. * common/asshelp.c (start_new_service): Likewise. * common/exectool.c (gnupg_exec_tool_stream): Likewise. * common/t-exechelp.c (test_pipe_stream): Likewise. * dirmngr/ldap-wrapper.c (ldap_wrapper): Likewise. * g10/photoid.c (run_with_pipe): Likewise. * scd/app.c (report_change): Likewise. * tests/gpgscm/ffi.c (do_process_spawn_io, do_process_spawn_fd): Likewise. * tools/gpg-card.c (cmd_gpg): Likewise. * tools/gpgconf-comp.c (gpg_agent_runtime_change): Likewise. (scdaemon_runtime_change, tpm2daemon_runtime_change) (dirmngr_runtime_change, keyboxd_runtime_change) (gc_component_launch, gc_component_check_options) (retrieve_options_from_program): Likewise. * tools/gpgconf.c (show_versions_via_dirmngr): Likewise. * tools/gpgtar-create.c (gpgtar_create): Likewise. * tools/gpgtar-extract.c (gpgtar_extract): Likewise. * tools/gpgtar-list.c (gpgtar_list): Likewise. -- Signed-off-by: NIIBE Yutaka <[email protected]>
Diffstat (limited to 'common/exechelp.h')
-rw-r--r--common/exechelp.h37
1 files changed, 16 insertions, 21 deletions
diff --git a/common/exechelp.h b/common/exechelp.h
index 0370b23a4..93ba12eeb 100644
--- a/common/exechelp.h
+++ b/common/exechelp.h
@@ -42,7 +42,7 @@ int get_max_fds (void);
EXCEPT is not NULL, it is expected to be a list of file descriptors
which are not to close. This list shall be sorted in ascending
order with its end marked by -1. */
-void close_all_fds (int first, int *except);
+void close_all_fds (int first, const int *except);
/* Returns an array with all currently open file descriptors. The end
@@ -75,22 +75,21 @@ void gnupg_close_pipe (int fd);
/* The opaque type for a subprocess. */
typedef struct gnupg_process *gnupg_process_t;
+typedef struct gnupg_spawn_actions *gnupg_spawn_actions_t;
+gpg_err_code_t gnupg_spawn_actions_new (gnupg_spawn_actions_t *r_act);
+void gnupg_spawn_actions_release (gnupg_spawn_actions_t act);
#ifdef HAVE_W32_SYSTEM
-struct spawn_cb_arg;
-#ifdef NEED_STRUCT_SPAWN_CB_ARG
-struct spawn_cb_arg {
- HANDLE hd[3];
- HANDLE *inherit_hds;
- BOOL allow_foreground_window;
- void *arg;
-};
-#endif
+void gnupg_spawn_actions_set_envvars (gnupg_spawn_actions_t, char *);
+void gnupg_spawn_actions_set_redirect (gnupg_spawn_actions_t,
+ void *, void *, void *);
+void gnupg_spawn_actions_set_inherit_handles (gnupg_spawn_actions_t, void **);
#else
-struct spawn_cb_arg {
- int fds[3];
- int *except_fds;
- void *arg;
-};
+void gnupg_spawn_actions_set_environ (gnupg_spawn_actions_t, char **);
+void gnupg_spawn_actions_set_redirect (gnupg_spawn_actions_t, int, int, int);
+void gnupg_spawn_actions_set_inherit_fds (gnupg_spawn_actions_t,
+ const int *);
+void gnupg_spawn_actions_set_atfork (gnupg_spawn_actions_t,
+ void (*atfork)(void *), void *arg);
#endif
#define GNUPG_PROCESS_DETACHED (1 << 1)
@@ -110,14 +109,10 @@ struct spawn_cb_arg {
#define GNUPG_PROCESS_STREAM_NONBLOCK (1 << 16)
-/* Spawn helper. */
-void gnupg_spawn_helper (struct spawn_cb_arg *sca);
-
/* Spawn PGMNAME. */
-gpg_err_code_t gnupg_process_spawn (const char *pgmname, const char *argv[],
+gpg_err_code_t gnupg_process_spawn (const char *pgmname, const char *argv1[],
unsigned int flags,
- void (*spawn_cb) (struct spawn_cb_arg *),
- void *spawn_cb_arg,
+ gnupg_spawn_actions_t act,
gnupg_process_t *r_process);
/* Get FDs for subprocess I/O. It is the caller which should care