Logo Search packages:      
Sourcecode: dbus version File versions

void _dbus_babysitter_unref ( DBusBabysitter sitter  ) 

Decrement the reference count on the babysitter object.

Parameters:
sitter the babysitter

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

References _dbus_assert, _dbus_strerror(), _dbus_warn(), _dbus_watch_invalidate(), _dbus_watch_list_free(), _dbus_watch_unref(), dbus_free(), DBusBabysitter::error_pipe_from_child, DBusBabysitter::error_watch, DBusBabysitter::executable, NULL, DBusBabysitter::refcount, DBusBabysitter::sitter_pid, DBusBabysitter::sitter_watch, DBusBabysitter::socket_to_babysitter, DBusBabysitter::status, and DBusBabysitter::watches.

Referenced by _dbus_spawn_async_with_babysitter().

{
  _dbus_assert (sitter != NULL);
  _dbus_assert (sitter->refcount > 0);
  
  sitter->refcount -= 1;
  if (sitter->refcount == 0)
    {      
      if (sitter->socket_to_babysitter >= 0)
        {
          close (sitter->socket_to_babysitter);
          sitter->socket_to_babysitter = -1;
        }

      if (sitter->error_pipe_from_child >= 0)
        {
          close (sitter->error_pipe_from_child);
          sitter->error_pipe_from_child = -1;
        }

      if (sitter->sitter_pid != -1)
        {
          int status;
          int ret;

          /* Reap the babysitter */
        again:
          ret = waitpid (sitter->sitter_pid, &status, 0);
          if (ret < 0)
            {
              if (errno == EINTR)
                goto again;
              else if (errno == ECHILD)
                _dbus_warn ("Babysitter process not available to be reaped; should not happen\n");
              else
                _dbus_warn ("Unexpected error %d in waitpid() for babysitter: %s\n",
                            errno, _dbus_strerror (errno));
            }
          else
            {
              _dbus_verbose ("Reaped %ld, waiting for babysitter %ld\n",
                             (long) ret, (long) sitter->sitter_pid);
              
              if (WIFEXITED (sitter->status))
                _dbus_verbose ("Babysitter exited with status %d\n",
                               WEXITSTATUS (sitter->status));
              else if (WIFSIGNALED (sitter->status))
                _dbus_verbose ("Babysitter received signal %d\n",
                               WTERMSIG (sitter->status));
              else
                _dbus_verbose ("Babysitter exited abnormally\n");
            }

          sitter->sitter_pid = -1;
        }
      
      if (sitter->error_watch)
        {
          _dbus_watch_invalidate (sitter->error_watch);
          _dbus_watch_unref (sitter->error_watch);
          sitter->error_watch = NULL;
        }

      if (sitter->sitter_watch)
        {
          _dbus_watch_invalidate (sitter->sitter_watch);
          _dbus_watch_unref (sitter->sitter_watch);
          sitter->sitter_watch = NULL;
        }
      
      if (sitter->watches)
        _dbus_watch_list_free (sitter->watches);

      dbus_free (sitter->executable);
      
      dbus_free (sitter);
    }
}


Generated by  Doxygen 1.6.0   Back to index