FreeBSD/contrib/ntp/libntp/ntp_worker.c
/*
 * pipe_socketpair()
 *
 * Provides an AF_UNIX socketpair on systems which have them, otherwise
 * pair of unidirectional pipes.
 */
pipe_socketpair()
Provides an AF_UNIX socketpair on systems which have them, otherwise
pair of unidirectional pipes.
pipe_socketpair () Provides an AF_UNIX socketpair on systems which have them otherwise pair of unidirectional pipes .
int
pipe_socketpair(
	int	caller_fds[2],
	int *	is_pipe
	)
{
	int	rc;
	int	fds[2];
	int	called_pipe;
#ifdef HAVE_SOCKETPAIR
	rc = socketpair(AF_UNIX, SOCK_STREAM, 0, &fds[0]);
#else
	rc = -1;
#endif
	if (-1 == rc) {
		rc = pipe(&fds[0]);
		called_pipe = TRUE;
	} else {
		called_pipe = FALSE;
	}
	if (-1 == rc)
		return rc;
	caller_fds[0] = fds[0];
	caller_fds[1] = fds[1];
	if (is_pipe != NULL)
		*is_pipe = called_pipe;
	return 0;
}
int pipe_socketpair ( int caller_fds [ 2 ] , int * is_pipe ) { int rc ; int fds [ 2 ] ; int called_pipe ; #ifdef HAVE_SOCKETPAIR rc = socketpair ( AF_UNIX , SOCK_STREAM , 0 , & fds [ 0 ] ) ; #else rc = -1 ; #endif if ( -1 == rc ) { rc = pipe ( & fds [ 0 ] ) ; called_pipe = TRUE ; } else { called_pipe = FALSE ; } if ( -1 == rc ) return rc ; caller_fds [ 0 ] = fds [ 0 ] ; caller_fds [ 1 ] = fds [ 1 ] ; if ( is_pipe != NULL ) * is_pipe = called_pipe ; return 0 ; }
pipe_socketpair()
 Provides an AF_UNIX socketpair on systems which have them, otherwise
 pair of unidirectional pipes.
pipe_socketpair () Provides an AF_UNIX socketpair on systems which have them otherwise pair of unidirectional pipes .