mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-08 12:44:23 +01:00
common,w32: Make use of default_errsource in exechelp.
* common/exechelp-posix.c (my_error_from_syserror, my_error): New. Use them instead of gpg_error and gpg_error_from_syserror. Fixes-commit: 96c7901ec1c79be732570811223d3ea54875abfe Signed-off-by: Justus Winter <justus@g10code.com>
This commit is contained in:
parent
34439da2d6
commit
727ca74bb9
@ -84,6 +84,20 @@
|
|||||||
# define handle_to_pid(a) ((int)(a))
|
# define handle_to_pid(a) ((int)(a))
|
||||||
|
|
||||||
|
|
||||||
|
/* Helper */
|
||||||
|
static inline gpg_error_t
|
||||||
|
my_error_from_syserror (void)
|
||||||
|
{
|
||||||
|
return gpg_err_make (default_errsource, gpg_err_code_from_syserror ());
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline gpg_error_t
|
||||||
|
my_error (int errcode)
|
||||||
|
{
|
||||||
|
return gpg_err_make (default_errsource, errcode);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Return the maximum number of currently allowed open file
|
/* Return the maximum number of currently allowed open file
|
||||||
descriptors. Only useful on POSIX systems but returns a value on
|
descriptors. Only useful on POSIX systems but returns a value on
|
||||||
other systems too. */
|
other systems too. */
|
||||||
@ -219,7 +233,7 @@ build_w32_commandline (const char *pgmname, const char * const *argv,
|
|||||||
|
|
||||||
buf = p = xtrymalloc (n);
|
buf = p = xtrymalloc (n);
|
||||||
if (!buf)
|
if (!buf)
|
||||||
return gpg_error_from_syserror ();
|
return my_error_from_syserror ();
|
||||||
|
|
||||||
p = build_w32_commandline_copy (p, pgmname);
|
p = build_w32_commandline_copy (p, pgmname);
|
||||||
for (i=0; argv[i]; i++)
|
for (i=0; argv[i]; i++)
|
||||||
@ -293,7 +307,7 @@ do_create_pipe (int filedes[2], int flags)
|
|||||||
HANDLE fds[2];
|
HANDLE fds[2];
|
||||||
|
|
||||||
filedes[0] = filedes[1] = -1;
|
filedes[0] = filedes[1] = -1;
|
||||||
err = gpg_error (GPG_ERR_GENERAL);
|
err = my_error (GPG_ERR_GENERAL);
|
||||||
if (!create_inheritable_pipe (fds, flags))
|
if (!create_inheritable_pipe (fds, flags))
|
||||||
{
|
{
|
||||||
filedes[0] = _open_osfhandle (handle_to_fd (fds[0]), O_RDONLY);
|
filedes[0] = _open_osfhandle (handle_to_fd (fds[0]), O_RDONLY);
|
||||||
@ -662,7 +676,7 @@ gnupg_spawn_process_fd (const char *pgmname, const char *argv[],
|
|||||||
))
|
))
|
||||||
{
|
{
|
||||||
log_error ("CreateProcess failed: %s\n", w32_strerror (-1));
|
log_error ("CreateProcess failed: %s\n", w32_strerror (-1));
|
||||||
err = gpg_error (GPG_ERR_GENERAL);
|
err = my_error (GPG_ERR_GENERAL);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
err = 0;
|
err = 0;
|
||||||
@ -707,7 +721,7 @@ gnupg_wait_processes (const char **pgmnames, pid_t *pids, size_t count,
|
|||||||
|
|
||||||
procs = xtrycalloc (count, sizeof *procs);
|
procs = xtrycalloc (count, sizeof *procs);
|
||||||
if (procs == NULL)
|
if (procs == NULL)
|
||||||
return gpg_error_from_syserror ();
|
return my_error_from_syserror ();
|
||||||
|
|
||||||
for (i = 0; i < count; i++)
|
for (i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
@ -715,7 +729,7 @@ gnupg_wait_processes (const char **pgmnames, pid_t *pids, size_t count,
|
|||||||
r_exitcodes[i] = -1;
|
r_exitcodes[i] = -1;
|
||||||
|
|
||||||
if (pids[i] == (pid_t)(-1))
|
if (pids[i] == (pid_t)(-1))
|
||||||
return gpg_error (GPG_ERR_INV_VALUE);
|
return my_error (GPG_ERR_INV_VALUE);
|
||||||
|
|
||||||
procs[i] = fd_to_handle (pids[i]);
|
procs[i] = fd_to_handle (pids[i]);
|
||||||
}
|
}
|
||||||
@ -818,7 +832,7 @@ gnupg_spawn_process_detached (const char *pgmname, const char *argv[],
|
|||||||
(void)envp;
|
(void)envp;
|
||||||
|
|
||||||
if (access (pgmname, X_OK))
|
if (access (pgmname, X_OK))
|
||||||
return gpg_error_from_syserror ();
|
return my_error_from_syserror ();
|
||||||
|
|
||||||
/* Prepare security attributes. */
|
/* Prepare security attributes. */
|
||||||
memset (&sec_attr, 0, sizeof sec_attr );
|
memset (&sec_attr, 0, sizeof sec_attr );
|
||||||
@ -856,7 +870,7 @@ gnupg_spawn_process_detached (const char *pgmname, const char *argv[],
|
|||||||
{
|
{
|
||||||
log_error ("CreateProcess(detached) failed: %s\n", w32_strerror (-1));
|
log_error ("CreateProcess(detached) failed: %s\n", w32_strerror (-1));
|
||||||
xfree (cmdline);
|
xfree (cmdline);
|
||||||
return gpg_error (GPG_ERR_GENERAL);
|
return my_error (GPG_ERR_GENERAL);
|
||||||
}
|
}
|
||||||
xfree (cmdline);
|
xfree (cmdline);
|
||||||
cmdline = NULL;
|
cmdline = NULL;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user