~ubuntu-branches/ubuntu/karmic/gnupg2/karmic-updates

« back to all changes in this revision

Viewing changes to common/exechelp.h

  • Committer: Bazaar Package Importer
  • Author(s): Thomas Viehmann
  • Date: 2008-10-04 10:25:53 UTC
  • mfrom: (5.1.15 intrepid)
  • Revision ID: james.westby@ubuntu.com-20081004102553-fv62pp8dsitxli47
Tags: 2.0.9-3.1
* Non-maintainer upload.
* agent/gpg-agent.c: Deinit the threading library before exec'ing
  the command to run in --daemon mode. And because that still doesn't
  restore the sigprocmask, do that manually. Closes: #499569

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
 *
6
6
 * GnuPG is free software; you can redistribute it and/or modify
7
7
 * it under the terms of the GNU General Public License as published by
8
 
 * the Free Software Foundation; either version 2 of the License, or
 
8
 * the Free Software Foundation; either version 3 of the License, or
9
9
 * (at your option) any later version.
10
10
 *
11
11
 * GnuPG is distributed in the hope that it will be useful,
14
14
 * GNU General Public License for more details.
15
15
 *
16
16
 * You should have received a copy of the GNU General Public License
17
 
 * along with this program; if not, write to the Free Software
18
 
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
 
17
 * along with this program; if not, see <http://www.gnu.org/licenses/>.
19
18
 */
20
19
 
21
20
#ifndef GNUPG_COMMON_EXECHELP_H
22
21
#define GNUPG_COMMON_EXECHELP_H
23
22
 
24
23
 
 
24
/* Portable function to create a pipe.  Under Windows the write end is
 
25
   inheritable.  */
 
26
gpg_error_t gnupg_create_inbound_pipe (int filedes[2]);
 
27
 
25
28
 
26
29
/* Fork and exec the PGMNAME, connect the file descriptor of INFILE to
27
30
   stdin, write the output to OUTFILE, return a new stream in
28
31
   STATUSFILE for stderr and the pid of the process in PID. The
29
32
   arguments for the process are expected in the NULL terminated array
30
 
   ARGV.  The program name itself should not be included there.  if
 
33
   ARGV.  The program name itself should not be included there.  If
31
34
   PREEXEC is not NULL, that function will be called right before the
32
 
   exec.  Returns 0 on success or an error code. */
 
35
   exec.  FLAGS is currently only useful for W32, see the source for
 
36
   details.  Calling gnupg_wait_process is required.  Returns 0 on
 
37
   success or an error code. */
33
38
gpg_error_t gnupg_spawn_process (const char *pgmname, const char *argv[],
34
39
                                 FILE *infile, FILE *outfile,
35
 
                                 void (*preexec)(void),
 
40
                                 void (*preexec)(void), unsigned int flags,
36
41
                                 FILE **statusfile, pid_t *pid);
37
42
 
 
43
 
 
44
/* Simplified version of gnupg_spawn_process.  This function forks and
 
45
   then execs PGMNAME, while connecting INFD to stdin, OUTFD to stdout
 
46
   and ERRFD to stderr (any of them may be -1 to connect them to
 
47
   /dev/null).  The arguments for the process are expected in the NULL
 
48
   terminated array ARGV.  The program name itself should not be
 
49
   included there.  Calling gnupg_wait_process is required.  Returns 0
 
50
   on success or an error code. */
 
51
gpg_error_t gnupg_spawn_process_fd (const char *pgmname, 
 
52
                                    const char *argv[],
 
53
                                    int infd, int outfd, int errfd,
 
54
                                    pid_t *pid);
 
55
 
 
56
 
38
57
/* Wait for the process identified by PID to terminate. PGMNAME should
39
 
   be the same as suplieed to the spawn fucntion and is only used for
40
 
   diagnostics. Returns 0 if the process succeded, GPG_ERR_GENERAL for
41
 
   any failures of the spawned program or other error codes.*/
42
 
gpg_error_t gnupg_wait_process (const char *pgmname, pid_t pid);
 
58
   be the same as supplied to the spawn fucntion and is only used for
 
59
   diagnostics.  Returns 0 if the process succeded, GPG_ERR_GENERAL
 
60
   for any failures of the spawned program or other error codes.  If
 
61
   EXITCODE is not NULL the exit code of the process is stored at this
 
62
   address or -1 if it could not be retrieved.  */
 
63
gpg_error_t gnupg_wait_process (const char *pgmname, pid_t pid, int *exitcode);
 
64
 
 
65
 
 
66
/* Spawn a new process and immediatley detach from it.  The name of
 
67
   the program to exec is PGMNAME and its arguments are in ARGV (the
 
68
   programname is automatically passed as first argument).
 
69
   Environment strings in ENVP are set.  An error is returned if
 
70
   pgmname is not executable; to make this work it is necessary to
 
71
   provide an absolute file name.  */
 
72
gpg_error_t gnupg_spawn_process_detached (const char *pgmname,
 
73
                                          const char *argv[],
 
74
                                          const char *envp[] );
 
75
 
43
76
 
44
77
 
45
78
#endif /*GNUPG_COMMON_EXECHELP_H*/