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