1 /* 2 * Distributed under the Boost Software License, Version 1.0. 3 * (See accompanying file LICENSE_1_0.txt or copy at 4 * http://www.boost.org/LICENSE_1_0.txt) 5 */ 6 module glib.gspawn; 7 8 import glib.gtypes; 9 import glib.gerror; 10 11 12 //enum G_SPAWN_ERROR = g_spawn_error_quark (); 13 14 15 enum GSpawnError 16 { 17 G_SPAWN_ERROR_FORK, /* fork failed due to lack of memory */ 18 G_SPAWN_ERROR_READ, /* read or select on pipes failed */ 19 G_SPAWN_ERROR_CHDIR, /* changing to working dir failed */ 20 G_SPAWN_ERROR_ACCES, /* execv() returned EACCES */ 21 G_SPAWN_ERROR_PERM, /* execv() returned EPERM */ 22 G_SPAWN_ERROR_TOO_BIG,/* execv() returned E2BIG */ 23 G_SPAWN_ERROR_NOEXEC, /* execv() returned ENOEXEC */ 24 G_SPAWN_ERROR_NAMETOOLONG, /* "" "" ENAMETOOLONG */ 25 G_SPAWN_ERROR_NOENT, /* "" "" ENOENT */ 26 G_SPAWN_ERROR_NOMEM, /* "" "" ENOMEM */ 27 G_SPAWN_ERROR_NOTDIR, /* "" "" ENOTDIR */ 28 G_SPAWN_ERROR_LOOP, /* "" "" ELOOP */ 29 G_SPAWN_ERROR_TXTBUSY, /* "" "" ETXTBUSY */ 30 G_SPAWN_ERROR_IO, /* "" "" EIO */ 31 G_SPAWN_ERROR_NFILE, /* "" "" ENFILE */ 32 G_SPAWN_ERROR_MFILE, /* "" "" EMFLE */ 33 G_SPAWN_ERROR_INVAL, /* "" "" EINVAL */ 34 G_SPAWN_ERROR_ISDIR, /* "" "" EISDIR */ 35 G_SPAWN_ERROR_LIBBAD, /* "" "" ELIBBAD */ 36 G_SPAWN_ERROR_FAILED /* other fatal failure, error->message 37 * should explain 38 */ 39 } 40 41 //enum G_SPAWN_EXIT_ERROR = g_spawn_exit_error_quark (); 42 43 44 extern(C) alias GSpawnChildSetupFunc = void function (gpointer user_data); 45 46 47 enum GSpawnFlags 48 { 49 G_SPAWN_DEFAULT = 0, 50 G_SPAWN_LEAVE_DESCRIPTORS_OPEN = 1 << 0, 51 G_SPAWN_DO_NOT_REAP_CHILD = 1 << 1, 52 /* look for argv[0] in the path i.e. use execvp() */ 53 G_SPAWN_SEARCH_PATH = 1 << 2, 54 /* Dump output to /dev/null */ 55 G_SPAWN_STDOUT_TO_DEV_NULL = 1 << 3, 56 G_SPAWN_STDERR_TO_DEV_NULL = 1 << 4, 57 G_SPAWN_CHILD_INHERITS_STDIN = 1 << 5, 58 G_SPAWN_FILE_AND_ARGV_ZERO = 1 << 6, 59 G_SPAWN_SEARCH_PATH_FROM_ENVP = 1 << 7, 60 G_SPAWN_CLOEXEC_PIPES = 1 << 8 61 } 62 63 64 extern (C) { 65 66 67 GQuark g_spawn_error_quark (); 68 69 GQuark g_spawn_exit_error_quark (); 70 71 gboolean g_spawn_check_exit_status (gint exit_status, 72 GError **error); 73 74 75 void g_spawn_close_pid (GPid pid); 76 77 78 version (Win32) { 79 80 81 82 alias g_spawn_async = g_spawn_async_utf8; 83 alias g_spawn_async_with_pipes = g_spawn_async_with_pipes_utf8; 84 alias g_spawn_sync = g_spawn_sync_utf8; 85 alias g_spawn_command_line_sync = g_spawn_command_line_sync_utf8; 86 alias g_spawn_command_line_async = g_spawn_command_line_async_utf8; 87 88 89 gboolean g_spawn_async_utf8 (const(gchar) *working_directory, 90 gchar **argv, 91 gchar **envp, 92 GSpawnFlags flags, 93 GSpawnChildSetupFunc child_setup, 94 gpointer user_data, 95 GPid *child_pid, 96 GError **error); 97 98 gboolean g_spawn_async_with_pipes_utf8 (const(gchar) *working_directory, 99 gchar **argv, 100 gchar **envp, 101 GSpawnFlags flags, 102 GSpawnChildSetupFunc child_setup, 103 gpointer user_data, 104 GPid *child_pid, 105 gint *standard_input, 106 gint *standard_output, 107 gint *standard_error, 108 GError **error); 109 110 gboolean g_spawn_sync_utf8 (const(gchar) *working_directory, 111 gchar **argv, 112 gchar **envp, 113 GSpawnFlags flags, 114 GSpawnChildSetupFunc child_setup, 115 gpointer user_data, 116 gchar **standard_output, 117 gchar **standard_error, 118 gint *exit_status, 119 GError **error); 120 121 122 gboolean g_spawn_command_line_sync_utf8 (const(gchar) *command_line, 123 gchar **standard_output, 124 gchar **standard_error, 125 gint *exit_status, 126 GError **error); 127 128 gboolean g_spawn_command_line_async_utf8 (const(gchar) *command_line, 129 GError **error); 130 131 } 132 else { 133 134 gboolean g_spawn_async (const(gchar) *working_directory, 135 gchar **argv, 136 gchar **envp, 137 GSpawnFlags flags, 138 GSpawnChildSetupFunc child_setup, 139 gpointer user_data, 140 GPid *child_pid, 141 GError **error); 142 143 144 gboolean g_spawn_async_with_pipes (const(gchar) *working_directory, 145 gchar **argv, 146 gchar **envp, 147 GSpawnFlags flags, 148 GSpawnChildSetupFunc child_setup, 149 gpointer user_data, 150 GPid *child_pid, 151 gint *standard_input, 152 gint *standard_output, 153 gint *standard_error, 154 GError **error); 155 156 157 158 gboolean g_spawn_sync (const(gchar) *working_directory, 159 gchar **argv, 160 gchar **envp, 161 GSpawnFlags flags, 162 GSpawnChildSetupFunc child_setup, 163 gpointer user_data, 164 gchar **standard_output, 165 gchar **standard_error, 166 gint *exit_status, 167 GError **error); 168 169 170 gboolean g_spawn_command_line_sync (const(gchar) *command_line, 171 gchar **standard_output, 172 gchar **standard_error, 173 gint *exit_status, 174 GError **error); 175 176 gboolean g_spawn_command_line_async (const(gchar) *command_line, 177 GError **error); 178 179 } 180 } 181