You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

140 lines
5.7 KiB

  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. #if defined(G_DISABLE_SINGLE_INCLUDES) && !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION)
  21. #error "Only <glib.h> can be included directly."
  22. #endif
  23. #ifndef __G_SPAWN_H__
  24. #define __G_SPAWN_H__
  25. #include <glib/gerror.h>
  26. G_BEGIN_DECLS
  27. /* I'm not sure I remember our proposed naming convention here. */
  28. #define G_SPAWN_ERROR g_spawn_error_quark ()
  29. typedef enum
  30. {
  31. G_SPAWN_ERROR_FORK, /* fork failed due to lack of memory */
  32. G_SPAWN_ERROR_READ, /* read or select on pipes failed */
  33. G_SPAWN_ERROR_CHDIR, /* changing to working dir failed */
  34. G_SPAWN_ERROR_ACCES, /* execv() returned EACCES */
  35. G_SPAWN_ERROR_PERM, /* execv() returned EPERM */
  36. G_SPAWN_ERROR_2BIG, /* execv() returned E2BIG */
  37. G_SPAWN_ERROR_NOEXEC, /* execv() returned ENOEXEC */
  38. G_SPAWN_ERROR_NAMETOOLONG, /* "" "" ENAMETOOLONG */
  39. G_SPAWN_ERROR_NOENT, /* "" "" ENOENT */
  40. G_SPAWN_ERROR_NOMEM, /* "" "" ENOMEM */
  41. G_SPAWN_ERROR_NOTDIR, /* "" "" ENOTDIR */
  42. G_SPAWN_ERROR_LOOP, /* "" "" ELOOP */
  43. G_SPAWN_ERROR_TXTBUSY, /* "" "" ETXTBUSY */
  44. G_SPAWN_ERROR_IO, /* "" "" EIO */
  45. G_SPAWN_ERROR_NFILE, /* "" "" ENFILE */
  46. G_SPAWN_ERROR_MFILE, /* "" "" EMFLE */
  47. G_SPAWN_ERROR_INVAL, /* "" "" EINVAL */
  48. G_SPAWN_ERROR_ISDIR, /* "" "" EISDIR */
  49. G_SPAWN_ERROR_LIBBAD, /* "" "" ELIBBAD */
  50. G_SPAWN_ERROR_FAILED /* other fatal failure, error->message
  51. * should explain
  52. */
  53. } GSpawnError;
  54. typedef void (* GSpawnChildSetupFunc) (gpointer user_data);
  55. typedef enum
  56. {
  57. G_SPAWN_LEAVE_DESCRIPTORS_OPEN = 1 << 0,
  58. G_SPAWN_DO_NOT_REAP_CHILD = 1 << 1,
  59. /* look for argv[0] in the path i.e. use execvp() */
  60. G_SPAWN_SEARCH_PATH = 1 << 2,
  61. /* Dump output to /dev/null */
  62. G_SPAWN_STDOUT_TO_DEV_NULL = 1 << 3,
  63. G_SPAWN_STDERR_TO_DEV_NULL = 1 << 4,
  64. G_SPAWN_CHILD_INHERITS_STDIN = 1 << 5,
  65. G_SPAWN_FILE_AND_ARGV_ZERO = 1 << 6
  66. } GSpawnFlags;
  67. GQuark g_spawn_error_quark (void);
  68. #ifdef G_OS_WIN32
  69. #define g_spawn_async g_spawn_async_utf8
  70. #define g_spawn_async_with_pipes g_spawn_async_with_pipes_utf8
  71. #define g_spawn_sync g_spawn_sync_utf8
  72. #define g_spawn_command_line_sync g_spawn_command_line_sync_utf8
  73. #define g_spawn_command_line_async g_spawn_command_line_async_utf8
  74. #endif
  75. gboolean g_spawn_async (const gchar *working_directory,
  76. gchar **argv,
  77. gchar **envp,
  78. GSpawnFlags flags,
  79. GSpawnChildSetupFunc child_setup,
  80. gpointer user_data,
  81. GPid *child_pid,
  82. GError **error);
  83. /* Opens pipes for non-NULL standard_output, standard_input, standard_error,
  84. * and returns the parent's end of the pipes.
  85. */
  86. gboolean g_spawn_async_with_pipes (const gchar *working_directory,
  87. gchar **argv,
  88. gchar **envp,
  89. GSpawnFlags flags,
  90. GSpawnChildSetupFunc child_setup,
  91. gpointer user_data,
  92. GPid *child_pid,
  93. gint *standard_input,
  94. gint *standard_output,
  95. gint *standard_error,
  96. GError **error);
  97. /* If standard_output or standard_error are non-NULL, the full
  98. * standard output or error of the command will be placed there.
  99. */
  100. gboolean g_spawn_sync (const gchar *working_directory,
  101. gchar **argv,
  102. gchar **envp,
  103. GSpawnFlags flags,
  104. GSpawnChildSetupFunc child_setup,
  105. gpointer user_data,
  106. gchar **standard_output,
  107. gchar **standard_error,
  108. gint *exit_status,
  109. GError **error);
  110. gboolean g_spawn_command_line_sync (const gchar *command_line,
  111. gchar **standard_output,
  112. gchar **standard_error,
  113. gint *exit_status,
  114. GError **error);
  115. gboolean g_spawn_command_line_async (const gchar *command_line,
  116. GError **error);
  117. void g_spawn_close_pid (GPid pid);
  118. G_END_DECLS
  119. #endif /* __G_SPAWN_H__ */