Logo Search packages:      
Sourcecode: dbus version File versions

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, or whatever). If the child process has not exited, does nothing (error will remain unset).

Parameters:
sitter the babysitter
error an error to fill in

Definition at line 610 of file dbus-spawn.c.

References _dbus_babysitter_get_child_exited(), _dbus_strerror(), dbus_set_error(), DBusBabysitter::errnum, DBusBabysitter::executable, DBusBabysitter::have_child_status, DBusBabysitter::have_exec_errnum, DBusBabysitter::have_fork_errnum, and DBusBabysitter::status.

{
  if (!_dbus_babysitter_get_child_exited (sitter))
    return;

  /* Note that if exec fails, we will also get a child status
   * from the babysitter saying the child exited,
   * so we need to give priority to the exec error
   */
  if (sitter->have_exec_errnum)
    {
      dbus_set_error (error, DBUS_ERROR_SPAWN_EXEC_FAILED,
                      "Failed to execute program %s: %s",
                      sitter->executable, _dbus_strerror (sitter->errnum));
    }
  else if (sitter->have_fork_errnum)
    {
      dbus_set_error (error, DBUS_ERROR_NO_MEMORY,
                      "Failed to fork a new process %s: %s",
                      sitter->executable, _dbus_strerror (sitter->errnum));
    }
  else if (sitter->have_child_status)
    {
      if (WIFEXITED (sitter->status))
        dbus_set_error (error, DBUS_ERROR_SPAWN_CHILD_EXITED,
                        "Process %s exited with status %d",
                        sitter->executable, WEXITSTATUS (sitter->status));
      else if (WIFSIGNALED (sitter->status))
        dbus_set_error (error, DBUS_ERROR_SPAWN_CHILD_SIGNALED,
                        "Process %s received signal %d",
                        sitter->executable, WTERMSIG (sitter->status));
      else
        dbus_set_error (error, DBUS_ERROR_FAILED,
                        "Process %s exited abnormally",
                        sitter->executable);
    }
  else
    {
      dbus_set_error (error, DBUS_ERROR_FAILED,
                      "Process %s exited, reason unknown",
                      sitter->executable);
    }
}


Generated by  Doxygen 1.6.0   Back to index