williamr@2: /* gspawn.h - Process launching williamr@2: * williamr@2: * Copyright 2000 Red Hat, Inc. williamr@2: * Portions copyright (c) 2006 Nokia Corporation. All rights reserved. williamr@2: * williamr@2: * GLib is free software; you can redistribute it and/or williamr@2: * modify it under the terms of the GNU Lesser General Public License as williamr@2: * published by the Free Software Foundation; either version 2 of the williamr@2: * License, or (at your option) any later version. williamr@2: * williamr@2: * GLib is distributed in the hope that it will be useful, williamr@2: * but WITHOUT ANY WARRANTY; without even the implied warranty of williamr@2: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU williamr@2: * Lesser General Public License for more details. williamr@2: * williamr@2: * You should have received a copy of the GNU Lesser General Public williamr@2: * License along with GLib; see the file COPYING.LIB. If not, write williamr@2: * to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, williamr@2: * Boston, MA 02111-1307, USA. williamr@2: */ williamr@2: williamr@2: #ifndef __G_SPAWN_H__ williamr@2: #define __G_SPAWN_H__ williamr@2: williamr@2: #include <_ansi.h> williamr@2: #include williamr@2: williamr@2: G_BEGIN_DECLS williamr@2: williamr@2: /* I'm not sure I remember our proposed naming convention here. */ williamr@2: #define G_SPAWN_ERROR g_spawn_error_quark () williamr@2: williamr@2: typedef enum williamr@2: { williamr@2: G_SPAWN_ERROR_FORK, /* fork failed due to lack of memory */ williamr@2: G_SPAWN_ERROR_READ, /* read or select on pipes failed */ williamr@2: G_SPAWN_ERROR_CHDIR, /* changing to working dir failed */ williamr@2: G_SPAWN_ERROR_ACCES, /* execv() returned EACCES */ williamr@2: G_SPAWN_ERROR_PERM, /* execv() returned EPERM */ williamr@2: G_SPAWN_ERROR_2BIG, /* execv() returned E2BIG */ williamr@2: G_SPAWN_ERROR_NOEXEC, /* execv() returned ENOEXEC */ williamr@2: G_SPAWN_ERROR_NAMETOOLONG, /* "" "" ENAMETOOLONG */ williamr@2: G_SPAWN_ERROR_NOENT, /* "" "" ENOENT */ williamr@2: G_SPAWN_ERROR_NOMEM, /* "" "" ENOMEM */ williamr@2: G_SPAWN_ERROR_NOTDIR, /* "" "" ENOTDIR */ williamr@2: G_SPAWN_ERROR_LOOP, /* "" "" ELOOP */ williamr@2: G_SPAWN_ERROR_TXTBUSY, /* "" "" ETXTBUSY */ williamr@2: G_SPAWN_ERROR_IO, /* "" "" EIO */ williamr@2: G_SPAWN_ERROR_NFILE, /* "" "" ENFILE */ williamr@2: G_SPAWN_ERROR_MFILE, /* "" "" EMFLE */ williamr@2: G_SPAWN_ERROR_INVAL, /* "" "" EINVAL */ williamr@2: G_SPAWN_ERROR_ISDIR, /* "" "" EISDIR */ williamr@2: G_SPAWN_ERROR_LIBBAD, /* "" "" ELIBBAD */ williamr@2: G_SPAWN_ERROR_FAILED /* other fatal failure, error->message williamr@2: * should explain williamr@2: */ williamr@2: } GSpawnError; williamr@2: williamr@2: typedef void (* GSpawnChildSetupFunc) (gpointer user_data); williamr@2: williamr@2: typedef enum williamr@2: { williamr@2: G_SPAWN_LEAVE_DESCRIPTORS_OPEN = 1 << 0, williamr@2: G_SPAWN_DO_NOT_REAP_CHILD = 1 << 1, williamr@2: /* look for argv[0] in the path i.e. use execvp() */ williamr@2: G_SPAWN_SEARCH_PATH = 1 << 2, williamr@2: /* Dump output to /dev/null */ williamr@2: G_SPAWN_STDOUT_TO_DEV_NULL = 1 << 3, williamr@2: G_SPAWN_STDERR_TO_DEV_NULL = 1 << 4, williamr@2: G_SPAWN_CHILD_INHERITS_STDIN = 1 << 5, williamr@2: G_SPAWN_FILE_AND_ARGV_ZERO = 1 << 6 williamr@2: } GSpawnFlags; williamr@2: williamr@2: IMPORT_C GQuark g_spawn_error_quark (void); williamr@2: williamr@2: #ifdef G_OS_WIN32 williamr@2: #define g_spawn_async g_spawn_async_utf8 williamr@2: #define g_spawn_async_with_pipes g_spawn_async_with_pipes_utf8 williamr@2: #define g_spawn_sync g_spawn_sync_utf8 williamr@2: #define g_spawn_command_line_sync g_spawn_command_line_sync_utf8 williamr@2: #define g_spawn_command_line_async g_spawn_command_line_async_utf8 williamr@2: #endif williamr@2: williamr@2: IMPORT_C gboolean g_spawn_async (const gchar *working_directory, williamr@2: gchar **argv, williamr@2: gchar **envp, williamr@2: GSpawnFlags flags, williamr@2: GSpawnChildSetupFunc child_setup, williamr@2: gpointer user_data, williamr@2: GPid *child_pid, williamr@2: GError **error); williamr@2: williamr@2: williamr@2: /* Opens pipes for non-NULL standard_output, standard_input, standard_error, williamr@2: * and returns the parent's end of the pipes. williamr@2: */ williamr@2: IMPORT_C gboolean g_spawn_async_with_pipes (const gchar *working_directory, williamr@2: gchar **argv, williamr@2: gchar **envp, williamr@2: GSpawnFlags flags, williamr@2: GSpawnChildSetupFunc child_setup, williamr@2: gpointer user_data, williamr@2: GPid *child_pid, williamr@2: gint *standard_input, williamr@2: gint *standard_output, williamr@2: gint *standard_error, williamr@2: GError **error); williamr@2: williamr@2: williamr@2: /* If standard_output or standard_error are non-NULL, the full williamr@2: * standard output or error of the command will be placed there. williamr@2: */ williamr@2: williamr@2: IMPORT_C gboolean g_spawn_sync (const gchar *working_directory, williamr@2: gchar **argv, williamr@2: gchar **envp, williamr@2: GSpawnFlags flags, williamr@2: GSpawnChildSetupFunc child_setup, williamr@2: gpointer user_data, williamr@2: gchar **standard_output, williamr@2: gchar **standard_error, williamr@2: gint *exit_status, williamr@2: GError **error); williamr@2: williamr@2: IMPORT_C gboolean g_spawn_command_line_sync (const gchar *command_line, williamr@2: gchar **standard_output, williamr@2: gchar **standard_error, williamr@2: gint *exit_status, williamr@2: GError **error); williamr@2: IMPORT_C gboolean g_spawn_command_line_async (const gchar *command_line, williamr@2: GError **error); williamr@2: williamr@2: IMPORT_C void g_spawn_close_pid (GPid pid); williamr@2: williamr@2: williamr@2: G_END_DECLS williamr@2: williamr@2: #endif /* __G_SPAWN_H__ */ williamr@2: williamr@2: