summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2009-10-13 21:17:24 +0200
committerWerner Koch <wk@gnupg.org>2009-10-13 21:17:24 +0200
commit536b6ab09fa3e17f955c8b55e8469f3265a1936f (patch)
treea06fba4fb448cc70de12a470d7dde7f22c3eaf8f /common
parentReplace C99 style vararg macro which was anyway not correct. (diff)
downloadgnupg2-536b6ab09fa3e17f955c8b55e8469f3265a1936f.tar.xz
gnupg2-536b6ab09fa3e17f955c8b55e8469f3265a1936f.zip
Keep on hacking on g13. A simple --create and --mount does now work.
A hacked up encfs is required.
Diffstat (limited to 'common')
-rw-r--r--common/ChangeLog4
-rw-r--r--common/exechelp.c25
-rw-r--r--common/exechelp.h6
-rw-r--r--common/iobuf.c14
4 files changed, 42 insertions, 7 deletions
diff --git a/common/ChangeLog b/common/ChangeLog
index 575c9ed1a..2c70240da 100644
--- a/common/ChangeLog
+++ b/common/ChangeLog
@@ -1,3 +1,7 @@
+2009-10-13 Werner Koch <wk@g10code.com>
+
+ * exechelp.c (gnupg_kill_process): New.
+
2009-09-29 Werner Koch <wk@g10code.com>
* exechelp.c (create_inheritable_pipe): Rename to
diff --git a/common/exechelp.c b/common/exechelp.c
index 89604902a..4a385bcd7 100644
--- a/common/exechelp.c
+++ b/common/exechelp.c
@@ -1102,3 +1102,28 @@ gnupg_spawn_process_detached (const char *pgmname, const char *argv[],
return 0;
#endif /* !HAVE_W32_SYSTEM*/
}
+
+
+/* Kill a process; that is send an appropriate signal to the process.
+ gnupg_wait_process must be called to actually remove the process
+ from the system. An invalid PID is ignored. */
+void
+gnupg_kill_process (pid_t pid)
+{
+#ifdef HAVE_W32_SYSTEM
+ /* Older versions of libassuan set PID to 0 on Windows to indicate
+ an invalid value. */
+ if (pid != (pid_t) INVALID_HANDLE_VALUE && pid != 0)
+ {
+ HANDLE process = (HANDLE) pid;
+
+ /* Arbitrary error code. */
+ TerminateProcess (process, 1);
+ }
+#else
+ if (pid != (pid_t)(-1))
+ {
+ kill (pid, SIGTERM);
+ }
+#endif
+}
diff --git a/common/exechelp.h b/common/exechelp.h
index 3d70e1096..8f056891c 100644
--- a/common/exechelp.h
+++ b/common/exechelp.h
@@ -86,6 +86,12 @@ gpg_error_t gnupg_spawn_process_fd (const char *pgmname,
gpg_error_t gnupg_wait_process (const char *pgmname, pid_t pid, int *exitcode);
+/* Kill a process; that is send an appropriate signal to the process.
+ gnupg_wait_process must be called to actually remove the process
+ from the system. An invalid PID is ignored. */
+void gnupg_kill_process (pid_t pid);
+
+
/* Spawn a new process and immediatley detach from it. The name of
the program to exec is PGMNAME and its arguments are in ARGV (the
programname is automatically passed as first argument).
diff --git a/common/iobuf.c b/common/iobuf.c
index e3ea0b4cb..60e50d677 100644
--- a/common/iobuf.c
+++ b/common/iobuf.c
@@ -1262,22 +1262,22 @@ iobuf_is_pipe_filename (const char *fname)
/* Either open the file specified by the file descriptor FD or - if FD
- is GNUPG_INVALID_FD - the file with name FNAME. As of now MODE is
- assumed to be "rb" if FNAME is used. In contrast to iobuf_fdopen
- the fiel descriptor FD will not be closed during an iobuf_close. */
+ is -1, the file with name FNAME. As of now MODE is assumed to be
+ "rb" if FNAME is used. In contrast to iobuf_fdopen the file
+ descriptor FD will not be closed during an iobuf_close. */
iobuf_t
-iobuf_open_fd_or_name (gnupg_fd_t fd, const char *fname, const char *mode)
+iobuf_open_fd_or_name (int fd, const char *fname, const char *mode)
{
iobuf_t a;
- if (fd == GNUPG_INVALID_FD)
+ if (fd == -1)
a = iobuf_open (fname);
else
{
- gnupg_fd_t fd2;
+ int fd2;
fd2 = dup (fd);
- if (fd2 == GNUPG_INVALID_FD)
+ if (fd2 == -1)
a = NULL;
else
a = iobuf_fdopen (fd2, mode);