dbus-spawn.h
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
/* dbus-spawn.h Wrapper around fork/exec
*
* Copyright (C) 2002, 2003 Red Hat, Inc.
* Copyright (C) 2003 CodeFactory AB
*
* SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
*
* Licensed under the Academic Free License version 2.1
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#ifndef DBUS_SPAWN_H
#define DBUS_SPAWN_H
#include <dbus/dbus-string.h>
#include <dbus/dbus-errors.h>
#include <dbus/dbus-watch.h>
DBUS_BEGIN_DECLS
typedef void (* DBusSpawnChildSetupFunc) (void *user_data);
typedef struct DBusBabysitter DBusBabysitter;
typedef void (* DBusBabysitterFinishedFunc) (DBusBabysitter *sitter,
void *user_data);
typedef enum {
DBUS_SPAWN_REDIRECT_OUTPUT = (1 << 0),
DBUS_SPAWN_SILENCE_OUTPUT = (1 << 1),
DBUS_SPAWN_NONE = 0
} DBusSpawnFlags;
dbus_bool_t _dbus_spawn_async_with_babysitter (DBusBabysitter **sitter_p,
const char *log_name,
char * const *argv,
char * const *env,
DBusSpawnFlags flags,
DBusSpawnChildSetupFunc child_setup,
void *user_data,
DBusError *error);
void _dbus_babysitter_set_result_function (DBusBabysitter *sitter,
DBusBabysitterFinishedFunc finished,
void *user_data);
DBusBabysitter* _dbus_babysitter_ref (DBusBabysitter *sitter);
void _dbus_babysitter_unref (DBusBabysitter *sitter);
void _dbus_babysitter_kill_child (DBusBabysitter *sitter);
dbus_bool_t _dbus_babysitter_get_child_exited (DBusBabysitter *sitter);
void _dbus_babysitter_set_child_exit_error (DBusBabysitter *sitter,
DBusError *error);
dbus_bool_t _dbus_babysitter_get_child_exit_status (DBusBabysitter *sitter,
int *status);
dbus_bool_t _dbus_babysitter_set_watch_functions (DBusBabysitter *sitter,
DBusAddWatchFunction add_function,
DBusRemoveWatchFunction remove_function,
DBusWatchToggledFunction toggled_function,
void *data,
DBusFreeFunction free_data_function);
void _dbus_babysitter_block_for_child_exit (DBusBabysitter *sitter);
DBUS_END_DECLS
#endif /* DBUS_SPAWN_H */
DBusWatchToggledFunction
void(* DBusWatchToggledFunction)(DBusWatch *watch, void *data)
Called when dbus_watch_get_enabled() may return a different value than it did before.
Definition dbus-connection.h:100
DBusAddWatchFunction
dbus_bool_t(* DBusAddWatchFunction)(DBusWatch *watch, void *data)
Called when libdbus needs a new watch to be monitored by the main loop.
Definition dbus-connection.h:94
DBusRemoveWatchFunction
void(* DBusRemoveWatchFunction)(DBusWatch *watch, void *data)
Called when libdbus no longer needs a watch to be monitored by the main loop.
Definition dbus-connection.h:106
_dbus_babysitter_get_child_exit_status
dbus_bool_t _dbus_babysitter_get_child_exit_status(DBusBabysitter *sitter, int *status)
Gets the exit status of the child.
Definition dbus-spawn-unix.c:753
_dbus_babysitter_unref
void _dbus_babysitter_unref(DBusBabysitter *sitter)
Decrement the reference count on the babysitter object.
Definition dbus-spawn-unix.c:336
_dbus_babysitter_get_child_exited
dbus_bool_t _dbus_babysitter_get_child_exited(DBusBabysitter *sitter)
Checks whether the child has exited, without blocking.
Definition dbus-spawn-unix.c:728
_dbus_babysitter_set_watch_functions
dbus_bool_t _dbus_babysitter_set_watch_functions(DBusBabysitter *sitter, DBusAddWatchFunction add_function, DBusRemoveWatchFunction remove_function, DBusWatchToggledFunction toggled_function, void *data, DBusFreeFunction free_data_function)
Sets watch functions to notify us when the babysitter object needs to read/write file descriptors.
Definition dbus-spawn-unix.c:835
_dbus_babysitter_set_child_exit_error
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,...
Definition dbus-spawn-unix.c:777
_dbus_babysitter_kill_child
void _dbus_babysitter_kill_child(DBusBabysitter *sitter)
Blocks until the babysitter process gives us the PID of the spawned grandchild, then kills the spawne...
Definition dbus-spawn-unix.c:706
_dbus_babysitter_ref
DBusBabysitter * _dbus_babysitter_ref(DBusBabysitter *sitter)
Increment the reference count on the babysitter object.
Definition dbus-spawn-unix.c:314
_dbus_spawn_async_with_babysitter
dbus_bool_t _dbus_spawn_async_with_babysitter(DBusBabysitter **sitter_p, const char *log_name, char *const *argv, char *const *env, DBusSpawnFlags flags, DBusSpawnChildSetupFunc child_setup, void *user_data, DBusError *error)
Spawns a new process.
Definition dbus-spawn-unix.c:1279
DBUS_BEGIN_DECLS
#define DBUS_BEGIN_DECLS
Macro used prior to declaring functions in the D-Bus header files.
Definition dbus-macros.h:36
DBUS_END_DECLS
#define DBUS_END_DECLS
Macro used after declaring functions in the D-Bus header files.
Definition dbus-macros.h:37
DBusFreeFunction
void(* DBusFreeFunction)(void *memory)
The type of a function which frees a block of memory.
Definition dbus-memory.h:65
dbus_bool_t
dbus_uint32_t dbus_bool_t
A boolean, valid values are TRUE and FALSE.
Definition dbus-types.h:37
DBusBabysitter
Babysitter implementation details.
Definition dbus-spawn-unix.c:252
DBusBabysitter::status
int status
Exit status code.
Definition dbus-spawn-unix.c:273
DBusBabysitter::log_name
char * log_name
the name under which to log messages about this process being spawned
Definition dbus-spawn-unix.c:255
DBusError
Object representing an exception.
Definition dbus-errors.h:51