Home GnuPG

spawn: Fix spawn_cb of gpgrt_spawn_process_fd.

Description

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: T6249
  • Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>

Details

Provenance
gniibeAuthored on Oct 31 2022, 3:07 AM
Parents
rE43c1e85fe29a: spawn: Expose spawn functions.
Branches
Unknown
Tags
Unknown
Tasks
T6249: gpgrt: spawn functions