aboutsummaryrefslogtreecommitdiffstats
path: root/src/gpg-error.h.in
diff options
context:
space:
mode:
authorNIIBE Yutaka <[email protected]>2022-10-31 02:07:57 +0000
committerNIIBE Yutaka <[email protected]>2022-10-31 02:07:57 +0000
commit6c20e8393eba4a9f330143b2158e28ea594cbadd (patch)
treee36258183639ef2df818806168e3ea34351ec89e /src/gpg-error.h.in
parentspawn: Expose spawn functions. (diff)
downloadlibgpg-error-6c20e8393eba4a9f330143b2158e28ea594cbadd.tar.gz
libgpg-error-6c20e8393eba4a9f330143b2158e28ea594cbadd.zip
spawn: Fix spawn_cb of gpgrt_spawn_process_fd.
* src/gpg-error.def.in (gpgrt_close_all_fds): New. * src/gpg-error.vers (gpgrt_close_all_fds): New. * src/gpg-error.h.in (GPGRT_SPAWN_INHERIT_FILE): New. (gpgrt_spawn_process_fd): SPAWN_CB having return value. * src/gpgrt-int.h (_gpgrt_spawn_process_fd): SPAWN_CB change. * src/spawn-posix.c (_gpgrt_close_all_fds): Rename from close_all_fds, and export it. (do_exec): Support the case not closing fds. (_gpgrt_spawn_process_fd): Handle return value of SPAWN_CB to determine closing all fds or not. * src/spawn-w32.c (_gpgrt_spawn_process_fd): Run SPAWN_CB. (_gpgrt_close_all_fds): New. * src/visibility.c (gpgrt_close_all_fds): New. * src/visibility.h (gpgrt_close_all_fds): New. -- Now, we have the API of gpgrt_spawn_process_fd for POSIX and Windows. Giving portable semantics for spawning a process is difficult, and it is still difficult for users to writing a function for SPAWN_CB with portability, but gpgrt_spawn_process_fd gives the feature of spawning a process. GnuPG-bug-id: 6249 Signed-off-by: NIIBE Yutaka <[email protected]>
Diffstat (limited to 'src/gpg-error.h.in')
-rw-r--r--src/gpg-error.h.in12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/gpg-error.h.in b/src/gpg-error.h.in
index b7cfdcf..ce5c76a 100644
--- a/src/gpg-error.h.in
+++ b/src/gpg-error.h.in
@@ -1084,6 +1084,9 @@ void _gpgrt_log_assert (const char *expr, const char *file, int line,
/*
* Spawn functions
*/
+/* Internal flag to ihnerit file descriptor/handle */
+#define GPGRT_SPAWN_INHERIT_FILE 1
+
#define GPGRT_SPAWN_NONBLOCK 16 /* Set the streams to non-blocking. */
#define GPGRT_SPAWN_RUN_ASFW 64 /* Use AllowSetForegroundWindow on W32. */
#define GPGRT_SPAWN_DETACHED 128 /* Start the process in the background. */
@@ -1110,14 +1113,14 @@ gpg_err_code_t gpgrt_spawn_process (const char *pgmname, const char *argv[],
/* Fork and exec PGNNAME and connect the process to the given FDs. */
gpg_err_code_t gpgrt_spawn_process_fd (const char *pgmname, const char *argv[],
int infd, int outfd, int errfd,
- void (*after_fork_cb)(void *),
- void *after_fork_cb_arg,
+ int (*spawn_cb) (void *),
+ void *spawn_cb_arg,
pid_t *pid);
/* Fork and exec PGMNAME as a detached process. */
gpg_err_code_t gpgrt_spawn_process_detached (const char *pgmname,
const char *argv[],
- const char *envp[] );
+ const char *envp[]);
/* Wait for a single process. */
gpg_err_code_t gpgrt_wait_process (const char *pgmname, pid_t pid, int hang,
@@ -1132,6 +1135,9 @@ void gpgrt_kill_process (pid_t pid);
/* Release process resources identified by PID. */
void gpgrt_release_process (pid_t pid);
+
+/* Close all file resources (descriptors), except KEEP_FDS. */
+void gpgrt_close_all_fds (int from, int *keep_fds);
/*
* Option parsing.