Logo Search packages:      
Sourcecode: dbus version File versions

dbus_bool_t _dbus_full_duplex_pipe ( int *  fd1,
int *  fd2,
dbus_bool_t  blocking,
DBusError error 
)

Creates a full-duplex pipe (as in socketpair()). Sets both ends of the pipe nonblocking.

Parameters:
fd1 return location for one end
fd2 return location for the other end
blocking TRUE if pipe should be blocking
error error return
Returns:
FALSE on failure (if error is set)

Definition at line 2990 of file dbus-sysdeps.c.

References _dbus_error_from_errno(), _dbus_set_fd_nonblocking(), _dbus_warn(), dbus_set_error(), FALSE, NULL, and TRUE.

Referenced by _dbus_spawn_async_with_babysitter().

{
#ifdef HAVE_SOCKETPAIR
  int fds[2];

  _DBUS_ASSERT_ERROR_IS_CLEAR (error);
  
  if (socketpair (AF_UNIX, SOCK_STREAM, 0, fds) < 0)
    {
      dbus_set_error (error, _dbus_error_from_errno (errno),
                      "Could not create full-duplex pipe");
      return FALSE;
    }

  if (!blocking &&
      (!_dbus_set_fd_nonblocking (fds[0], NULL) ||
       !_dbus_set_fd_nonblocking (fds[1], NULL)))
    {
      dbus_set_error (error, _dbus_error_from_errno (errno),
                      "Could not set full-duplex pipe nonblocking");
      
      close (fds[0]);
      close (fds[1]);
      
      return FALSE;
    }
  
  *fd1 = fds[0];
  *fd2 = fds[1];

  _dbus_verbose ("full-duplex pipe %d <-> %d\n",
                 *fd1, *fd2);
  
  return TRUE;  
#else
  _dbus_warn ("_dbus_full_duplex_pipe() not implemented on this OS\n");
  dbus_set_error (error, DBUS_ERROR_FAILED,
                  "_dbus_full_duplex_pipe() not implemented on this OS");
  return FALSE;
#endif
}


Generated by  Doxygen 1.6.0   Back to index