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,
60 static const char arg_does_not_exist[] =
"/this/does/not/exist/32542sdgafgafdg";
68 argv[0] = arg_does_not_exist;
70 (
char *
const *) argv,
71 NULL, DBUS_SPAWN_NONE, NULL, NULL,
74 _dbus_babysitter_block_for_child_exit (sitter);
83 _dbus_warn (
"Did not get an error launching nonexistent executable");
90 _dbus_warn (
"Not expecting error when launching nonexistent executable: %s: %s",
102 check_spawn_segfault (
void *data,
112 argv[0] = get_test_exec (
"test-segfault", &argv0);
121 NULL, DBUS_SPAWN_NONE, NULL, NULL,
124 _dbus_babysitter_block_for_child_exit (sitter);
135 _dbus_warn (
"Did not get an error launching segfaulting binary");
146 _dbus_warn (
"Not expecting error when launching segfaulting executable: %s: %s",
158 check_spawn_exit (
void *data,
168 argv[0] = get_test_exec (
"test-exit", &argv0);
177 NULL, DBUS_SPAWN_NONE, NULL, NULL,
180 _dbus_babysitter_block_for_child_exit (sitter);
191 _dbus_warn (
"Did not get an error launching binary that exited with failure code");
198 _dbus_warn (
"Not expecting error when launching exiting executable: %s: %s",
210 check_spawn_and_kill (
void *data,
220 argv[0] = get_test_exec (
"test-sleep-forever", &argv0);
229 NULL, DBUS_SPAWN_NONE, NULL, NULL,
234 _dbus_babysitter_block_for_child_exit (sitter);
246 _dbus_warn (
"Did not get an error after killing spawned binary");
257 _dbus_warn (
"Not expecting error when killing executable: %s: %s",
269 _dbus_spawn_test (
const char *test_data_dir)
271 if (!_dbus_test_oom_handling (
"spawn_nonexistent",
272 check_spawn_nonexistent,
276 if (!_dbus_test_oom_handling (
"spawn_segfault",
277 check_spawn_segfault,
281 if (!_dbus_test_oom_handling (
"spawn_exit",
286 if (!_dbus_test_oom_handling (
"spawn_and_kill",
287 check_spawn_and_kill,
dbus_bool_t dbus_error_has_name(const DBusError *error, const char *name)
Checks whether the error is set and has the given name.
const char * message
public error message field
#define NULL
A null pointer, defined appropriately for C or C++.
#define DBUS_ERROR_SPAWN_EXEC_FAILED
While starting a new process, the exec() call failed.
#define DBUS_ERROR_SPAWN_CHILD_EXITED
While starting a new process, the child exited with a status code.
#define DBUS_ERROR_INIT
Expands to a suitable initializer for a DBusError on the stack.
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...
dbus_bool_t _dbus_string_init(DBusString *str)
Initializes a string.
#define DBUS_ERROR_SPAWN_CHILD_SIGNALED
While starting a new process, the child exited on a signal.
dbus_uint32_t dbus_bool_t
A boolean, valid values are TRUE and FALSE.
void _dbus_babysitter_kill_child(DBusBabysitter *sitter)
Blocks until the babysitter process gives us the PID of the spawned grandchild, then kills the spawne...
Babysitter implementation details.
void _dbus_warn(const char *format,...)
Prints a warning message to stderr.
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.
dbus_bool_t _dbus_string_append_printf(DBusString *str, const char *format,...)
Appends a printf-style formatted string to the DBusString.
Object representing an exception.
void _dbus_string_free(DBusString *str)
Frees a string created by _dbus_string_init(), and fills it with the same contents as #_DBUS_STRING_I...
#define TRUE
Expands to "1".
const char * name
public error name field
void _dbus_babysitter_unref(DBusBabysitter *sitter)
Decrement the reference count on the babysitter object.
#define DBUS_ERROR_NO_MEMORY
There was not enough memory to complete an operation.
#define FALSE
Expands to "0".
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...
const char * _dbus_getenv(const char *varname)
Wrapper for getenv().
dbus_bool_t dbus_error_is_set(const DBusError *error)
Checks whether an error occurred (the error is set).