mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-02 22:46:30 +02:00
common: Change calling convention for gnupg_spawn_process.
* common/exechelp.h (GNUPG_SPAWN_NONBLOCK): New. (GNUPG_SPAWN_RUN_ASFW, GNUPG_SPAWN_DETACHED): Macro to replace the numbers. * common/exechelp.h (gnupg_spawn_process): Change function to not take an optional stream for stdin but to return one. * common/exechelp-posix.c (gnupg_spawn_process): Implement change. (create_pipe_and_estream): Add args outbound and nonblock. * common/exechelp-w32.c (gnupg_spawn_process): Implement change. -- In 2.1 this function is only used at one place and the stdin parameter is not used. Thus this change is trivial for the callers but along with estream's new es_poll it is overall simpler to use. Note that the Windows version has not been tested. Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
parent
6bb7206e35
commit
83811e3f1f
4 changed files with 128 additions and 60 deletions
|
@ -59,17 +59,22 @@ gpg_error_t gnupg_create_inbound_pipe (int filedes[2]);
|
|||
inheritable. */
|
||||
gpg_error_t gnupg_create_outbound_pipe (int filedes[2]);
|
||||
|
||||
#define GNUPG_SPAWN_NONBLOCK 16
|
||||
#define GNUPG_SPAWN_RUN_ASFW 64
|
||||
#define GNUPG_SPAWN_DETACHED 128
|
||||
|
||||
/* Fork and exec the PGMNAME. If INFP is NULL connect /dev/null to
|
||||
stdin of the new process; if it is not NULL connect the file
|
||||
descriptor retrieved from INFP to stdin. If R_OUTFP is NULL
|
||||
connect stdout of the new process to /dev/null; if it is not NULL
|
||||
store the address of a pointer to a new estream there. If R_ERRFP
|
||||
is NULL connect stderr of the new process to /dev/null; if it is
|
||||
not NULL store the address of a pointer to a new estream there. On
|
||||
success the pid of the new process is stored at PID. On error -1
|
||||
is stored at PID and if R_OUTFP or R_ERRFP are not NULL, NULL is
|
||||
stored there.
|
||||
|
||||
/* Fork and exec the program PGMNAME.
|
||||
|
||||
If R_INFP is NULL connect stdin of the new process to /dev/null; if
|
||||
it is not NULL store the address of a pointer to a new estream
|
||||
there. If R_OUTFP is NULL connect stdout of the new process to
|
||||
/dev/null; if it is not NULL store the address of a pointer to a
|
||||
new estream there. If R_ERRFP is NULL connect stderr of the new
|
||||
process to /dev/null; if it is not NULL store the address of a
|
||||
pointer to a new estream there. On success the pid of the new
|
||||
process is stored at PID. On error -1 is stored at PID and if
|
||||
R_OUTFP or R_ERRFP are not NULL, NULL is stored there.
|
||||
|
||||
The arguments for the process are expected in the NULL terminated
|
||||
array ARGV. The program name itself should not be included there.
|
||||
|
@ -81,12 +86,21 @@ gpg_error_t gnupg_create_outbound_pipe (int filedes[2]);
|
|||
|
||||
FLAGS is a bit vector:
|
||||
|
||||
Bit 7: If set the process will be started as a background process.
|
||||
GNUPG_SPAWN_NONBLOCK
|
||||
If set the two output streams are created in non-blocking
|
||||
mode and the input stream is switched to non-blocking mode.
|
||||
This is merely a convenience feature because the caller
|
||||
could do the same with gpgrt_set_nonblock. Does not yet
|
||||
work for Windows.
|
||||
|
||||
GNUPG_SPAWN_DETACHED
|
||||
If set the process will be started as a background process.
|
||||
This flag is only useful under W32 (but not W32CE) systems,
|
||||
so that no new console is created and pops up a console
|
||||
window when starting the server. Does not work on W32CE.
|
||||
|
||||
Bit 6: On W32 (but not on W32CE) run AllowSetForegroundWindow for
|
||||
GNUPG_SPAWN_RUN_ASFW
|
||||
On W32 (but not on W32CE) run AllowSetForegroundWindow for
|
||||
the child. Note that due to unknown problems this actually
|
||||
allows SetForegroundWindow for all childs of this process.
|
||||
|
||||
|
@ -95,7 +109,7 @@ gpg_error_t
|
|||
gnupg_spawn_process (const char *pgmname, const char *argv[],
|
||||
gpg_err_source_t errsource,
|
||||
void (*preexec)(void), unsigned int flags,
|
||||
estream_t infp,
|
||||
estream_t *r_infp,
|
||||
estream_t *r_outfp,
|
||||
estream_t *r_errfp,
|
||||
pid_t *pid);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue