'\" te .\" Copyright 1989 AT&T .\" Copyright (C) 2004, Sun Microsystems, Inc. All Rights Reserved .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License. .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License. .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner] .TH REXEC 3SOCKET "Feb 10, 2004" .SH NAME rexec, rexec_af \- return stream to a remote command .SH SYNOPSIS .LP .nf \fBcc\fR [ \fIflag\fR ... ] \fIfile\fR... \fB-lsocket\fR \fB -lnsl \fR [ \fIlibrary\fR... ] #include #include \fBint\fR \fBrexec\fR(\fBchar **\fR\fIahost\fR, \fBunsigned short\fR \fIinport\fR, \fBconst char *\fR\fIuser\fR, \fBconst char *\fR\fIpasswd\fR, \fBconst char *\fR\fIcmd\fR, \fBint *\fR\fIfd2p\fR); .fi .LP .nf \fBint\fR \fBrexec_af\fR(\fBchar **\fR\fIahost\fR, \fBunsigned short\fR \fIinport\fR, \fBconst char *\fR\fIuser\fR, \fBconst char *\fR\fIpasswd\fR, \fBconst char *\fR\fIcmd\fR, \fBint *\fR\fIfd2p\fR, \fBint\fR \fIaf\fR); .fi .SH DESCRIPTION .sp .LP The \fBrexec()\fR and \fBrexec_af()\fR functions look up the host \fIahost\fR using \fBgetaddrinfo\fR(3SOCKET) and return \fB\(mi1\fR if the host does not exist. Otherwise \fIahost\fR is set to the standard name of the host. The username and password are used in remote host authentication. When a username and password are not specified, the \fB\&.netrc\fR file in the user's home directory is searched for the appropriate information. If the search fails, the user is prompted for the information. .sp .LP The \fBrexec()\fR function always returns a socket of the \fBAF_INET\fR address family. The \fBrexec_af()\fR function supports \fBAF_INET\fR, \fBAF_INET6\fR, or \fBAF_UNSPEC\fR for the address family. An application can choose which type of socket is returned by passing \fBAF_INET\fR or \fBAF_INET6\fR as the address family. The use of \fBAF_UNSPEC\fR means that the caller will accept any address family. Choosing \fBAF_UNSPEC\fR provides a socket that best suits the connectivity to the remote host. .sp .LP The port \fIinport\fR specifies which \fBDARPA\fR Internet port to use for the connection. The port number used must be in network byte order, as supplied by a call to \fBhtons\fR(3XNET). The protocol for connection is described in detail in \fBin.rexecd\fR(1M). .sp .LP If the call succeeds, a socket of type \fBSOCK_STREAM\fR is returned to the caller, and given to the remote command as its standard input and standard output. If \fIfd2p\fR is non-zero, an auxiliary channel to a control process is set up and a file descriptor for it is placed in *\fIfd2p\fR. The control process returns diagnostic output (file descriptor 2), from the command on the auxiliary channel. The control process also accepts bytes on this channel as signal numbers to be forwarded to the process group of the command. If \fIfd2p\fR is 0, the standard error (file descriptor 2) of the remote command is made the same as its standard output. No provision is made for sending arbitrary signals to the remote process, other than possibly sending out-of-band data. .sp .LP There is no way to specify options to the \fBsocket()\fR call made by the \fBrexec()\fR or \fBrexec_af()\fRfunctions. .SH RETURN VALUES .sp .LP If \fBrexec()\fR succeeds, a file descriptor number is returned of the socket type \fBSOCK_STREAM\fR and the address family \fBAF_INET\fR. The parameter *\fIahost\fR is set to the standard name of the host. If the value of \fIfd2p\fR is other than \fBNULL\fR, a file descriptor number is placed in *\fIfd2p\fR which represents the standard error stream of the command. .sp .LP If \fBrexec_af()\fR succeeds, the routine returns a file descriptor number of the socket type \fBSOCK_STREAM\fR in the address family \fBAF_INET\fR or \fBAF_INET6\fR, as determined by the value of the \fIaf\fR parameter. .sp .LP If either \fBrexec()\fR or \fBrexec_af()\fR fails, \fB\(mi1\fR is returned. .SH ATTRIBUTES .sp .LP See \fBattributes\fR(5) for descriptions of the following attributes: .sp .sp .TS box; c | c l | l . ATTRIBUTE TYPE ATTRIBUTE VALUE _ MT-Level Unsafe .TE .sp .LP This interface is Unsafe in multithreaded applications. Unsafe interfaces should be called only from the main thread. .SH SEE ALSO .sp .LP \fBin.rexecd\fR(1M), \fBgetaddrinfo\fR(3SOCKET), \fBgethostbyname\fR(3NSL), \fBgetservbyname\fR(3SOCKET), \fBhtonl\fR(3XNET), \fBsocket\fR(3SOCKET), \fBattributes\fR(5)