mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-02 22:46:30 +02:00
common,agent,gpg,dirmngr,g13,scd,tests,tools: New spawn function.
* common/exechelp-posix.c (do_exec, gnupg_spawn_process): Remove. (check_syscall_func, pre_syscall, post_syscall) : New. (do_create_socketpair, posix_open_null, call_spawn_cb): New. (my_exec, spawn_detached, gnupg_spawn_helper): New. (gnupg_process_spawn, process_kill, gnupg_process_terminate): New. (gnupg_process_get_fds, gnupg_process_get_streams): New. (process_vctl, gnupg_process_ctl): New. (gnupg_process_wait, gnupg_process_release): New. (gnupg_process_wait_list): New. * common/exechelp-w32.c: Add definition of _WIN32_WINNT as 0x600. (check_syscall_func, pre_syscall, post_syscall): New. (gnupg_spawn_process): Remove. (check_windows_version): New. (spawn_detached, gnupg_spawn_helper, gnupg_process_spawn): New. (gnupg_process_get_fds, gnupg_process_get_streams): New. (process_kill, process_vctl, gnupg_process_ctl): New. (gnupg_process_wait, gnupg_process_terminate): New. (gnupg_process_release, gnupg_process_wait_list): New. * common/exechelp.h: Re-write for new API. * common/exectool.c (gnupg_exec_tool_stream): Follow the change. * common/asshelp.c (start_new_service): Likewise. * agent/genkey.c (do_check_passphrase_pattern): Likewise. * dirmngr/ldap-wrapper.c (struct wrapper_context_s): Use PROC. (destroy_wrapper): Follow the change of API. (read_log_data): Follow the change of API, use printable_pid. (ldap_reaper_thread, ldap_wrapper_release_context): Likewise. (ldap_wrapper_connection_cleanup, ldap_wrapper): Likewise. * g10/photoid.c (run_with_pipe): Follow the change of API. (show_photo): Likewise. * g13/be-encfs.c (run_umount_helper): Likewise. (run_encfs_tool): Likewise. * g13/g13.c: Add including ./common/exechelp.h. * g13/mount.c: Likewise. * g13/runner.c: Follow the change of API. * g13/runner.h: Follow the change of API. * scd/app.c (setup_env): New. (report_change): Follow the change of API. * tests/gpgscm/ffi.c (proc_object_finalize): New. (proc_object_to_string): New. (proc_wrap, proc_unwrap): New. (do_spawn_process): Remove. (do_process_spawn): New. (setup_std_fds): New. (do_spawn_process_fd): Remove. (do_process_spawn_fd): New. (do_wait_process): Remove. (do_process_wait): New. (do_wait_processes): Remove. * tests/gpgscm/t-child.scm: Follow the change of API. * tests/gpgscm/tests.scm: Likewise. * tests/openpgp/defs.scm: Likewise. * tests/tpm2dtests/defs.scm: Likewise. * tools/gpg-card.c: Likewise. * tools/gpgconf-comp.c: Likewise. * tools/gpgconf.c: Likewise. * tools/gpgtar-create.c: Likewise. * tools/gpgtar-extract.c: Likewise. * tools/gpgtar-list.c: Likewise. -- GnuPG-bug-id: 6275 Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
This commit is contained in:
parent
1e41878bf2
commit
a035938216
25 changed files with 1936 additions and 1621 deletions
|
@ -1069,7 +1069,7 @@ gpgtar_create (char **inpattern, const char *files_from, int null_names,
|
|||
estream_t files_from_stream = NULL;
|
||||
estream_t outstream = NULL;
|
||||
int eof_seen = 0;
|
||||
pid_t pid = (pid_t)(-1);
|
||||
gnupg_process_t proc = NULL;
|
||||
unsigned int skipped_open = 0;
|
||||
|
||||
memset (scanctrl, 0, sizeof *scanctrl);
|
||||
|
@ -1284,14 +1284,15 @@ gpgtar_create (char **inpattern, const char *files_from, int null_names,
|
|||
goto leave;
|
||||
}
|
||||
|
||||
err = gnupg_spawn_process (opt.gpg_program, argv,
|
||||
except[0] == -1? NULL : except,
|
||||
(GNUPG_SPAWN_KEEP_STDOUT
|
||||
| GNUPG_SPAWN_KEEP_STDERR),
|
||||
&outstream, NULL, NULL, &pid);
|
||||
err = gnupg_process_spawn (opt.gpg_program, argv,
|
||||
(GNUPG_PROCESS_STDIN_PIPE
|
||||
| GNUPG_PROCESS_STDOUT_KEEP
|
||||
| GNUPG_PROCESS_STDERR_KEEP),
|
||||
gnupg_spawn_helper, except, &proc);
|
||||
xfree (argv);
|
||||
if (err)
|
||||
goto leave;
|
||||
gnupg_process_get_streams (proc, 0, &outstream, NULL, NULL);
|
||||
es_set_binary (outstream);
|
||||
}
|
||||
else if (opt.outfile) /* No crypto */
|
||||
|
@ -1330,23 +1331,25 @@ gpgtar_create (char **inpattern, const char *files_from, int null_names,
|
|||
write_progress (1, global_written_files, global_total_files);
|
||||
write_progress (0, global_written_data, global_total_data);
|
||||
|
||||
if (pid != (pid_t)(-1))
|
||||
if (proc)
|
||||
{
|
||||
int exitcode;
|
||||
|
||||
err = es_fclose (outstream);
|
||||
outstream = NULL;
|
||||
if (err)
|
||||
log_error ("error closing pipe: %s\n", gpg_strerror (err));
|
||||
else
|
||||
|
||||
err = gnupg_process_wait (proc, 1);
|
||||
if (!err)
|
||||
{
|
||||
err = gnupg_wait_process (opt.gpg_program, pid, 1, &exitcode);
|
||||
if (err)
|
||||
int exitcode;
|
||||
|
||||
gnupg_process_ctl (proc, GNUPG_PROCESS_GET_EXIT_ID, &exitcode);
|
||||
if (exitcode)
|
||||
log_error ("running %s failed (exitcode=%d): %s",
|
||||
opt.gpg_program, exitcode, gpg_strerror (err));
|
||||
gnupg_release_process (pid);
|
||||
pid = (pid_t)(-1);
|
||||
}
|
||||
gnupg_process_release (proc);
|
||||
proc = NULL;
|
||||
}
|
||||
|
||||
if (skipped_open)
|
||||
|
@ -1359,7 +1362,7 @@ gpgtar_create (char **inpattern, const char *files_from, int null_names,
|
|||
if (!err)
|
||||
{
|
||||
gpg_error_t first_err;
|
||||
if (outstream != es_stdout || pid != (pid_t)(-1))
|
||||
if (outstream != es_stdout)
|
||||
first_err = es_fclose (outstream);
|
||||
else
|
||||
first_err = es_fflush (outstream);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue