source: trunk/third/glib2/glib/gspawn.h @ 20721

Revision 20721, 5.3 KB checked in by ghudson, 20 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r20720, which included commits to RCS files with non-trunk default branches.
Line 
1/* gspawn.h - Process launching
2 *
3 *  Copyright 2000 Red Hat, Inc.
4 *
5 * GLib is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public License as
7 * published by the Free Software Foundation; either version 2 of the
8 * License, or (at your option) any later version.
9 *
10 * GLib is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with GLib; see the file COPYING.LIB.  If not, write
17 * to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.
19 */
20
21#ifndef __G_SPAWN_H__
22#define __G_SPAWN_H__
23
24#include <glib/gerror.h>
25
26G_BEGIN_DECLS
27
28/* I'm not sure I remember our proposed naming convention here. */
29#define G_SPAWN_ERROR g_spawn_error_quark ()
30
31typedef enum
32{
33  G_SPAWN_ERROR_FORK,   /* fork failed due to lack of memory */
34  G_SPAWN_ERROR_READ,   /* read or select on pipes failed */
35  G_SPAWN_ERROR_CHDIR,  /* changing to working dir failed */
36  G_SPAWN_ERROR_ACCES,  /* execv() returned EACCES */
37  G_SPAWN_ERROR_PERM,   /* execv() returned EPERM */
38  G_SPAWN_ERROR_2BIG,   /* execv() returned E2BIG */
39  G_SPAWN_ERROR_NOEXEC, /* execv() returned ENOEXEC */
40  G_SPAWN_ERROR_NAMETOOLONG, /* ""  "" ENAMETOOLONG */
41  G_SPAWN_ERROR_NOENT,       /* ""  "" ENOENT */
42  G_SPAWN_ERROR_NOMEM,       /* ""  "" ENOMEM */
43  G_SPAWN_ERROR_NOTDIR,      /* ""  "" ENOTDIR */
44  G_SPAWN_ERROR_LOOP,        /* ""  "" ELOOP   */
45  G_SPAWN_ERROR_TXTBUSY,     /* ""  "" ETXTBUSY */
46  G_SPAWN_ERROR_IO,          /* ""  "" EIO */
47  G_SPAWN_ERROR_NFILE,       /* ""  "" ENFILE */
48  G_SPAWN_ERROR_MFILE,       /* ""  "" EMFLE */
49  G_SPAWN_ERROR_INVAL,       /* ""  "" EINVAL */
50  G_SPAWN_ERROR_ISDIR,       /* ""  "" EISDIR */
51  G_SPAWN_ERROR_LIBBAD,      /* ""  "" ELIBBAD */
52  G_SPAWN_ERROR_FAILED       /* other fatal failure, error->message
53                              * should explain
54                              */
55} GSpawnError;
56
57typedef void (* GSpawnChildSetupFunc) (gpointer user_data);
58
59typedef enum
60{
61  G_SPAWN_LEAVE_DESCRIPTORS_OPEN = 1 << 0,
62  G_SPAWN_DO_NOT_REAP_CHILD      = 1 << 1,
63  /* look for argv[0] in the path i.e. use execvp() */
64  G_SPAWN_SEARCH_PATH            = 1 << 2,
65  /* Dump output to /dev/null */
66  G_SPAWN_STDOUT_TO_DEV_NULL     = 1 << 3,
67  G_SPAWN_STDERR_TO_DEV_NULL     = 1 << 4,
68  G_SPAWN_CHILD_INHERITS_STDIN   = 1 << 5,
69  G_SPAWN_FILE_AND_ARGV_ZERO     = 1 << 6
70} GSpawnFlags;
71
72GQuark g_spawn_error_quark (void);
73
74gboolean g_spawn_async (const gchar           *working_directory,
75                        gchar                **argv,
76                        gchar                **envp,
77                        GSpawnFlags            flags,
78                        GSpawnChildSetupFunc   child_setup,
79                        gpointer               user_data,
80                        GPid                  *child_pid,
81                        GError               **error);
82
83
84/* Opens pipes for non-NULL standard_output, standard_input, standard_error,
85 * and returns the parent's end of the pipes.
86 */
87gboolean g_spawn_async_with_pipes (const gchar          *working_directory,
88                                   gchar               **argv,
89                                   gchar               **envp,
90                                   GSpawnFlags           flags,
91                                   GSpawnChildSetupFunc  child_setup,
92                                   gpointer              user_data,
93                                   GPid                 *child_pid,
94                                   gint                 *standard_input,
95                                   gint                 *standard_output,
96                                   gint                 *standard_error,
97                                   GError              **error);
98
99
100/* If standard_output or standard_error are non-NULL, the full
101 * standard output or error of the command will be placed there.
102 */
103
104gboolean g_spawn_sync         (const gchar          *working_directory,
105                               gchar               **argv,
106                               gchar               **envp,
107                               GSpawnFlags           flags,
108                               GSpawnChildSetupFunc  child_setup,
109                               gpointer              user_data,
110                               gchar               **standard_output,
111                               gchar               **standard_error,
112                               gint                 *exit_status,
113                               GError              **error);
114
115gboolean g_spawn_command_line_sync  (const gchar          *command_line,
116                                     gchar               **standard_output,
117                                     gchar               **standard_error,
118                                     gint                 *exit_status,
119                                     GError              **error);
120gboolean g_spawn_command_line_async (const gchar          *command_line,
121                                     GError              **error);
122
123void g_spawn_close_pid (GPid pid);
124
125
126G_END_DECLS
127
128#endif /* __G_SPAWN_H__ */
129
130
Note: See TracBrowser for help on using the repository browser.