aboutsummaryrefslogtreecommitdiffstats
path: root/common/exechelp.h
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2015-09-28 16:10:21 +0000
committerWerner Koch <[email protected]>2015-09-28 16:40:38 +0000
commit83811e3f1f0c615b2b63bafdb49a35a0fc198088 (patch)
tree676f6c145331d2911969ad01db7fcea6f6132c80 /common/exechelp.h
parentscd: Handle error correctly. (diff)
downloadgnupg-83811e3f1f0c615b2b63bafdb49a35a0fc198088.tar.gz
gnupg-83811e3f1f0c615b2b63bafdb49a35a0fc198088.zip
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 <[email protected]>
Diffstat (limited to 'common/exechelp.h')
-rw-r--r--common/exechelp.h40
1 files changed, 27 insertions, 13 deletions
diff --git a/common/exechelp.h b/common/exechelp.h
index a9a9ca304..a146d893a 100644
--- a/common/exechelp.h
+++ b/common/exechelp.h
@@ -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);