gspawn.h

Go to the documentation of this file.
00001 /* gspawn.h - Process launching
00002  *
00003  *  Copyright 2000 Red Hat, Inc.
00004  *
00005  * GLib is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU Lesser General Public License as
00007  * published by the Free Software Foundation; either version 2 of the
00008  * License, or (at your option) any later version.
00009  *
00010  * GLib is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013  * Lesser General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU Lesser General Public
00016  * License along with GLib; see the file COPYING.LIB.  If not, write
00017  * to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00018  * Boston, MA 02111-1307, USA.
00019  */
00020 
00021 #ifndef __G_SPAWN_H__
00022 #define __G_SPAWN_H__
00023 
00024 #include <gerror.h>
00025 
00026 G_BEGIN_DECLS
00027 
00028 /* I'm not sure I remember our proposed naming convention here. */
00029 #define G_SPAWN_ERROR g_spawn_error_quark ()
00030 
00031 typedef enum
00032 {
00033   G_SPAWN_ERROR_FORK,   /* fork failed due to lack of memory */
00034   G_SPAWN_ERROR_READ,   /* read or select on pipes failed */
00035   G_SPAWN_ERROR_CHDIR,  /* changing to working dir failed */
00036   G_SPAWN_ERROR_ACCES,  /* execv() returned EACCES */
00037   G_SPAWN_ERROR_PERM,   /* execv() returned EPERM */
00038   G_SPAWN_ERROR_2BIG,   /* execv() returned E2BIG */
00039   G_SPAWN_ERROR_NOEXEC, /* execv() returned ENOEXEC */
00040   G_SPAWN_ERROR_NAMETOOLONG, /* ""  "" ENAMETOOLONG */
00041   G_SPAWN_ERROR_NOENT,       /* ""  "" ENOENT */
00042   G_SPAWN_ERROR_NOMEM,       /* ""  "" ENOMEM */
00043   G_SPAWN_ERROR_NOTDIR,      /* ""  "" ENOTDIR */
00044   G_SPAWN_ERROR_LOOP,        /* ""  "" ELOOP   */
00045   G_SPAWN_ERROR_TXTBUSY,     /* ""  "" ETXTBUSY */
00046   G_SPAWN_ERROR_IO,          /* ""  "" EIO */
00047   G_SPAWN_ERROR_NFILE,       /* ""  "" ENFILE */
00048   G_SPAWN_ERROR_MFILE,       /* ""  "" EMFLE */
00049   G_SPAWN_ERROR_INVAL,       /* ""  "" EINVAL */
00050   G_SPAWN_ERROR_ISDIR,       /* ""  "" EISDIR */
00051   G_SPAWN_ERROR_LIBBAD,      /* ""  "" ELIBBAD */
00052   G_SPAWN_ERROR_FAILED       /* other fatal failure, error->message
00053                               * should explain
00054                               */
00055 } GSpawnError;
00056 
00057 typedef void (* GSpawnChildSetupFunc) (gpointer user_data);
00058 
00059 typedef enum
00060 {
00061   G_SPAWN_LEAVE_DESCRIPTORS_OPEN = 1 << 0,
00062   G_SPAWN_DO_NOT_REAP_CHILD = 1 << 1,
00063   /* look for argv[0] in the path i.e. use execvp() */
00064   G_SPAWN_SEARCH_PATH = 1 << 2,
00065   /* Dump output to /dev/null */
00066   G_SPAWN_STDOUT_TO_DEV_NULL = 1 << 3,
00067   G_SPAWN_STDERR_TO_DEV_NULL = 1 << 4,
00068   G_SPAWN_CHILD_INHERITS_STDIN = 1 << 5
00069 } GSpawnFlags;
00070 
00071 GQuark g_spawn_error_quark (void);
00072 
00073 gboolean g_spawn_async (const gchar           *working_directory,
00074                         gchar                **argv,
00075                         gchar                **envp,
00076                         GSpawnFlags            flags,
00077                         GSpawnChildSetupFunc   child_setup,
00078                         gpointer               user_data,
00079                         gint                  *child_pid,
00080                         GError               **error);
00081 
00082 
00083 /* Opens pipes for non-NULL standard_output, standard_input, standard_error,
00084  * and returns the parent's end of the pipes.
00085  */
00086 gboolean g_spawn_async_with_pipes (const gchar          *working_directory,
00087                                    gchar               **argv,
00088                                    gchar               **envp,
00089                                    GSpawnFlags           flags,
00090                                    GSpawnChildSetupFunc  child_setup,
00091                                    gpointer              user_data,
00092                                    gint                 *child_pid,
00093                                    gint                 *standard_input,
00094                                    gint                 *standard_output,
00095                                    gint                 *standard_error,
00096                                    GError              **error);
00097 
00098 
00099 /* If standard_output or standard_error are non-NULL, the full
00100  * standard output or error of the command will be placed there.
00101  */
00102 
00103 gboolean g_spawn_sync         (const gchar          *working_directory,
00104                                gchar               **argv,
00105                                gchar               **envp,
00106                                GSpawnFlags           flags,
00107                                GSpawnChildSetupFunc  child_setup,
00108                                gpointer              user_data,
00109                                gchar               **standard_output,
00110                                gchar               **standard_error,
00111                                gint                 *exit_status,
00112                                GError              **error);
00113 
00114 gboolean g_spawn_command_line_sync  (const gchar          *command_line,
00115                                      gchar               **standard_output,
00116                                      gchar               **standard_error,
00117                                      gint                 *exit_status,
00118                                      GError              **error);
00119 gboolean g_spawn_command_line_async (const gchar          *command_line,
00120                                      GError              **error);
00121 
00122 
00123 G_END_DECLS
00124 
00125 #endif /* __G_SPAWN_H__ */
00126 
00127 

Generated on Tue Jul 5 14:14:41 2011 for ROOT_528-00b_version by  doxygen 1.5.1