1rexec(3SOCKET) Sockets Library Functions rexec(3SOCKET)
2
3
4
6 rexec, rexec_af - return stream to a remote command
7
9 cc [ flag ... ] file... -lsocket -lnsl [ library... ]
10 #include <netdb.h>
11 #include <unistd.h>
12
13 int rexec(char **ahost, unsigned short inport, const char *user,
14 const char *passwd, const char *cmd, int *fd2p);
15
16
17 int rexec_af(char **ahost, unsigned short inport, const char *user,
18 const char *passwd, const char *cmd, int *fd2p, int af);
19
20
22 The rexec() and rexec_af() functions look up the host ahost using
23 getaddrinfo(3SOCKET) and return −1 if the host does not exist. Other‐
24 wise ahost is set to the standard name of the host. The username and
25 password are used in remote host authentication. When a username and
26 password are not specified, the .netrc file in the user's home direc‐
27 tory is searched for the appropriate information. If the search fails,
28 the user is prompted for the information.
29
30
31 The rexec() function always returns a socket of the AF_INET address
32 family. The rexec_af() function supports AF_INET, AF_INET6, or
33 AF_UNSPEC for the address family. An application can choose which type
34 of socket is returned by passing AF_INET or AF_INET6 as the address
35 family. The use of AF_UNSPEC means that the caller will accept any
36 address family. Choosing AF_UNSPEC provides a socket that best suits
37 the connectivity to the remote host.
38
39
40 The port inport specifies which DARPA Internet port to use for the con‐
41 nection. The port number used must be in network byte order, as sup‐
42 plied by a call to htons(3XNET). The protocol for connection is
43 described in detail in in.rexecd(1M).
44
45
46 If the call succeeds, a socket of type SOCK_STREAM is returned to the
47 caller, and given to the remote command as its standard input and stan‐
48 dard output. If fd2p is non-zero, an auxiliary channel to a control
49 process is set up and a file descriptor for it is placed in *fd2p. The
50 control process returns diagnostic output (file descriptor 2), from the
51 command on the auxiliary channel. The control process also accepts
52 bytes on this channel as signal numbers to be forwarded to the process
53 group of the command. If fd2p is 0, the standard error (file descriptor
54 2) of the remote command is made the same as its standard output. No
55 provision is made for sending arbitrary signals to the remote process,
56 other than possibly sending out-of-band data.
57
58
59 There is no way to specify options to the socket() call made by the
60 rexec() or rexec_af()functions.
61
63 If rexec() succeeds, a file descriptor number is returned of the socket
64 type SOCK_STREAM and the address family AF_INET. The parameter *ahost
65 is set to the standard name of the host. If the value of fd2p is other
66 than NULL, a file descriptor number is placed in *fd2p which represents
67 the standard error stream of the command.
68
69
70 If rexec_af() succeeds, the routine returns a file descriptor number of
71 the socket type SOCK_STREAM in the address family AF_INET or AF_INET6,
72 as determined by the value of the af parameter.
73
74
75 If either rexec() or rexec_af() fails, −1 is returned.
76
78 See attributes(5) for descriptions of the following attributes:
79
80
81
82
83 ┌─────────────────────────────┬─────────────────────────────┐
84 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
85 ├─────────────────────────────┼─────────────────────────────┤
86 │MT-Level │Unsafe │
87 └─────────────────────────────┴─────────────────────────────┘
88
89
90 This interface is Unsafe in multithreaded applications. Unsafe inter‐
91 faces should be called only from the main thread.
92
94 in.rexecd(1M), getaddrinfo(3SOCKET), gethostbyname(3NSL), getservby‐
95 name(3SOCKET), htonl(3XNET), socket(3SOCKET), attributes(5)
96
97
98
99SunOS 5.11 10 Feb 2004 rexec(3SOCKET)