28 #include "dbus-spawn.h" 
   29 #include "dbus-sysdeps.h" 
   30 #include "dbus-test.h" 
   33 get_test_exec (
const char *exe,
 
   36   const char *dbus_test_exec;
 
   40   if (dbus_test_exec == 
NULL)
 
   47                                    dbus_test_exec, exe, DBUS_EXEEXT))
 
   53   return _dbus_string_get_data (scratch_space);
 
   57 check_spawn_nonexistent (
void *data)
 
   59   static const char arg_does_not_exist[] = 
"/this/does/not/exist/32542sdgafgafdg";
 
   67   argv[0] = arg_does_not_exist;
 
   69                                          (
char * 
const *) argv,
 
   73       _dbus_babysitter_block_for_child_exit (sitter);
 
   82       _dbus_warn (
"Did not get an error launching nonexistent executable");
 
   89       _dbus_warn (
"Not expecting error when launching nonexistent executable: %s: %s",
 
  101 check_spawn_segfault (
void *data)
 
  110   argv[0] = get_test_exec (
"test-segfault", &argv0);
 
  122       _dbus_babysitter_block_for_child_exit (sitter);
 
  133       _dbus_warn (
"Did not get an error launching segfaulting binary");
 
  144       _dbus_warn (
"Not expecting error when launching segfaulting executable: %s: %s",
 
  156 check_spawn_exit (
void *data)
 
  165   argv[0] = get_test_exec (
"test-exit", &argv0);
 
  177       _dbus_babysitter_block_for_child_exit (sitter);
 
  188       _dbus_warn (
"Did not get an error launching binary that exited with failure code");
 
  195       _dbus_warn (
"Not expecting error when launching exiting executable: %s: %s",
 
  207 check_spawn_and_kill (
void *data)
 
  216   argv[0] = get_test_exec (
"test-sleep-forever", &argv0);
 
  230       _dbus_babysitter_block_for_child_exit (sitter);
 
  242       _dbus_warn (
"Did not get an error after killing spawned binary");
 
  253       _dbus_warn (
"Not expecting error when killing executable: %s: %s",
 
  265 _dbus_spawn_test (
const char *test_data_dir)
 
  267   if (!_dbus_test_oom_handling (
"spawn_nonexistent",
 
  268                                 check_spawn_nonexistent,
 
  272   if (!_dbus_test_oom_handling (
"spawn_segfault",
 
  273                                 check_spawn_segfault,
 
  277   if (!_dbus_test_oom_handling (
"spawn_exit",
 
  282   if (!_dbus_test_oom_handling (
"spawn_and_kill",
 
  283                                 check_spawn_and_kill,
 
  
void _dbus_string_free(DBusString *str)
Frees a string created by _dbus_string_init().
void _dbus_babysitter_set_child_exit_error(DBusBabysitter *sitter, DBusError *error)
Sets the DBusError with an explanation of why the spawned child process exited (on a signal,...
#define DBUS_ERROR_SPAWN_CHILD_SIGNALED
While starting a new process, the child exited on a signal.
dbus_bool_t _dbus_spawn_async_with_babysitter(DBusBabysitter **sitter_p, const char *log_name, char *const *argv, char **env, DBusSpawnFlags flags, DBusSpawnChildSetupFunc child_setup, void *user_data, DBusError *error)
Spawns a new process.
#define DBUS_ERROR_SPAWN_CHILD_EXITED
While starting a new process, the child exited with a status code.
dbus_bool_t _dbus_string_init(DBusString *str)
Initializes a string.
#define DBUS_ERROR_SPAWN_EXEC_FAILED
While starting a new process, the exec() call failed.
dbus_bool_t dbus_error_has_name(const DBusError *error, const char *name)
Checks whether the error is set and has the given name.
dbus_bool_t _dbus_string_append_printf(DBusString *str, const char *format,...)
Appends a printf-style formatted string to the DBusString.
const char * name
public error name field
Babysitter implementation details.
#define DBUS_ERROR_NO_MEMORY
There was not enough memory to complete an operation.
dbus_bool_t dbus_error_is_set(const DBusError *error)
Checks whether an error occurred (the error is set).
void dbus_error_free(DBusError *error)
Frees an error that's been set (or just initialized), then reinitializes the error as in dbus_error_i...
void _dbus_babysitter_unref(DBusBabysitter *sitter)
Decrement the reference count on the babysitter object.
void _dbus_warn(const char *format,...)
Prints a warning message to stderr.
const char * _dbus_getenv(const char *varname)
Wrapper for getenv().
Object representing an exception.
const char * message
public error message field
void _dbus_babysitter_kill_child(DBusBabysitter *sitter)
Blocks until the babysitter process gives us the PID of the spawned grandchild, then kills the spawne...
dbus_uint32_t dbus_bool_t