summaryrefslogtreecommitdiffstats
path: root/man7/unix.7
diff options
context:
space:
mode:
Diffstat (limited to 'man7/unix.7')
-rw-r--r--man7/unix.7168
1 files changed, 85 insertions, 83 deletions
diff --git a/man7/unix.7 b/man7/unix.7
index 71cdfc758..0501f7b80 100644
--- a/man7/unix.7
+++ b/man7/unix.7
@@ -73,19 +73,19 @@ On Linux,
is 108 bytes in size; see also BUGS, below.
.P
Various systems calls (for example,
-.BR bind (2),
-.BR connect (2),
+.MR bind 2 ,
+.MR connect 2 ,
and
-.BR sendto (2))
+.MR sendto 2 )
take a
.I sockaddr_un
argument as input.
Some other system calls (for example,
-.BR getsockname (2),
-.BR getpeername (2),
-.BR recvfrom (2),
+.MR getsockname 2 ,
+.MR getpeername 2 ,
+.MR recvfrom 2 ,
and
-.BR accept (2))
+.MR accept 2 )
return an argument of this type.
.P
Three types of address are distinguished in the
@@ -95,7 +95,7 @@ structure:
pathname
a UNIX domain socket can be bound to a null-terminated
filesystem pathname using
-.BR bind (2).
+.MR bind 2 .
When the address of a pathname socket is returned
(by one of the system calls noted above),
its length is
@@ -123,10 +123,10 @@ For further details of pathname sockets, see below.
.TP
unnamed
A stream socket that has not been bound to a pathname using
-.BR bind (2)
+.MR bind 2
has no name.
Likewise, the two sockets created by
-.BR socketpair (2)
+.MR socketpair 2
are unnamed.
When the address of an unnamed socket is returned,
its length is
@@ -205,10 +205,11 @@ as short as 92 bytes.
.\" Solaris and Irix have 108
.P
Various system calls
-.RB ( accept (2),
-.BR recvfrom (2),
-.BR getsockname (2),
-.BR getpeername (2))
+\%(\c
+.MR accept 2 ,
+.MR recvfrom 2 ,
+.MR getsockname 2 ,
+.MR getpeername 2 )
return socket address structures.
When applied to UNIX domain sockets, the value-result
.I addrlen
@@ -242,23 +243,23 @@ When creating a new socket, the owner and group of the socket file
are set according to the usual rules.
The socket file has all permissions enabled,
other than those that are turned off by the process
-.BR umask (2).
+.MR umask 2 .
.P
The owner, group, and permissions of a pathname socket can be changed (using
-.BR chown (2)
+.MR chown 2
and
-.BR chmod (2)).
+.MR chmod 2 ).
.\" However, fchown() and fchmod() do not seem to have an effect
.\"
.SS Abstract sockets
Socket permissions have no meaning for abstract sockets:
the process
-.BR umask (2)
+.MR umask 2
has no effect when binding an abstract socket,
and changing the ownership and permissions of the object (via
-.BR fchown (2)
+.MR fchown 2
and
-.BR fchmod (2))
+.MR fchmod 2 )
has no effect on the accessibility of the socket.
.P
Abstract sockets automatically disappear when all open references
@@ -273,9 +274,9 @@ type even though they are
.B AF_UNIX
specific.
They can be set with
-.BR setsockopt (2)
+.MR setsockopt 2
and read with
-.BR getsockopt (2)
+.MR getsockopt 2
by specifying
.B SOL_SOCKET
as the socket family.
@@ -296,9 +297,9 @@ When this option is set and the socket is not yet connected,
a unique name in the abstract namespace will be generated automatically.
.IP
The value given as an argument to
-.BR setsockopt (2)
+.MR setsockopt 2
and returned as the result of
-.BR getsockopt (2)
+.MR getsockopt 2
is an integer boolean flag.
.TP
.B SO_PASSSEC
@@ -308,9 +309,9 @@ in an ancillary message of type
(see below).
.IP
The value given as an argument to
-.BR setsockopt (2)
+.MR setsockopt 2
and returned as the result of
-.BR getsockopt (2)
+.MR getsockopt 2
is an integer boolean flag.
.IP
The
@@ -324,20 +325,20 @@ in Linux 4.2.
.TP
.B SO_PEEK_OFF
See
-.BR socket (7).
+.MR socket 7 .
.TP
.B SO_PEERCRED
This read-only socket option returns the
credentials of the peer process connected to this socket.
The returned credentials are those that were in effect at the time
of the call to
-.BR connect (2),
-.BR listen (2),
+.MR connect 2 ,
+.MR listen 2 ,
or
-.BR socketpair (2).
+.MR socketpair 2 .
.IP
The argument to
-.BR getsockopt (2)
+.MR getsockopt 2
is a pointer to a
.I ucred
structure; define the
@@ -350,7 +351,7 @@ The use of this option is possible only for connected
stream sockets and for
.B AF_UNIX
stream and datagram socket pairs created using
-.BR socketpair (2).
+.MR socketpair 2 .
.TP
.B SO_PEERSEC
This read-only socket option returns the
@@ -360,12 +361,12 @@ the process that created the peer socket unless overridden
by the policy or by a process with the required permissions.
.IP
The argument to
-.BR getsockopt (2)
+.MR getsockopt 2
is a pointer to a buffer of the specified length in bytes
into which the security context string will be copied.
If the buffer length is less than the length of the security
context string, then
-.BR getsockopt (2)
+.MR getsockopt 2
returns \-1, sets
.I errno
to
@@ -394,11 +395,11 @@ address family is supported since Linux 2.6.2 for connected stream sockets,
and since Linux 4.18
.\" commit 0b811db2cb2aabc910e53d34ebb95a15997c33e7
also for stream and datagram socket pairs created using
-.BR socketpair (2).
+.MR socketpair 2 .
.\"
.SS Autobind feature
If a
-.BR bind (2)
+.MR bind 2
call specifies
.I addrlen
as
@@ -424,12 +425,12 @@ UNIX domain sockets do not support the transmission of
out-of-band data (the
.B MSG_OOB
flag for
-.BR send (2)
+.MR send 2
and
-.BR recv (2)).
+.MR recv 2 ).
.P
The
-.BR send (2)
+.MR send 2
.B MSG_MORE
flag is not supported by UNIX domain sockets.
.P
@@ -440,7 +441,7 @@ the use of
in the
.I flags
argument of
-.BR recv (2)
+.MR recv 2
was not supported by UNIX domain sockets.
.P
The
@@ -452,13 +453,13 @@ For datagram sockets, the
.B SO_SNDBUF
value imposes an upper limit on the size of outgoing datagrams.
This limit is calculated as the doubled (see
-.BR socket (7))
+.MR socket 7 )
option value less 32 bytes used for overhead.
.SS Ancillary messages
Ancillary data is sent and received using
-.BR sendmsg (2)
+.MR sendmsg 2
and
-.BR recvmsg (2).
+.MR recvmsg 2 .
For historical reasons, the ancillary message types listed below
are specified with a
.B SOL_SOCKET
@@ -475,7 +476,7 @@ and the
.I cmsg_type
field to the type.
For more information, see
-.BR cmsg (3).
+.MR cmsg 3 .
.TP
.B SCM_RIGHTS
Send or receive a set of open file descriptors from another process.
@@ -485,11 +486,12 @@ Commonly, this operation is referred to as "passing a file descriptor"
to another process.
However, more accurately,
what is being passed is a reference to an open file description (see
-.BR open (2)),
+.MR open 2 ),
and in the receiving process it is likely that a different
file descriptor number will be used.
Semantically, this operation is equivalent to duplicating
-.RB ( dup (2))
+\%(\c
+.MR dup 2 )
a file descriptor into the file descriptor table of another process.
.IP
If the buffer used to receive the ancillary data containing
@@ -502,7 +504,7 @@ If the number of file descriptors received in the ancillary data would
cause the process to exceed its
.B RLIMIT_NOFILE
resource limit (see
-.BR getrlimit (2)),
+.MR getrlimit 2 ),
the excess file descriptors are automatically closed
in the receiving process.
.IP
@@ -510,7 +512,7 @@ The kernel constant
.B SCM_MAX_FD
defines a limit on the number of file descriptors in the array.
Attempting to send an array larger than this limit causes
-.BR sendmsg (2)
+.MR sendmsg 2
to fail with the error
.BR EINVAL .
.B SCM_MAX_FD
@@ -576,7 +578,7 @@ To receive the security context, the
option must be enabled on the socket (see above).
.P
When sending ancillary data with
-.BR sendmsg (2),
+.MR sendmsg 2 ,
only one item of each of the above types may be included in the sent message.
.P
At least one byte of real data should be sent when sending ancillary data.
@@ -594,23 +596,23 @@ For example, suppose that the sender transmits as follows:
.RS
.PD 0
.IP (1) 5
-.BR sendmsg (2)
+.MR sendmsg 2
of four bytes, with no ancillary data.
.IP (2)
-.BR sendmsg (2)
+.MR sendmsg 2
of one byte, with ancillary data.
.IP (3)
-.BR sendmsg (2)
+.MR sendmsg 2
of four bytes, with no ancillary data.
.PD
.RE
.P
Suppose that the receiver now performs
-.BR recvmsg (2)
+.MR recvmsg 2
calls each with a buffer size of 20 bytes.
The first call will receive five bytes of data,
along with the ancillary data sent by the second
-.BR sendmsg (2)
+.MR sendmsg 2
call.
The next call will receive the remaining four bytes of data.
.P
@@ -624,7 +626,7 @@ If no buffer is provided for incoming ancillary data (i.e., the
field of the
.I msghdr
structure supplied to
-.BR recvmsg (2)
+.MR recvmsg 2
is NULL),
then the incoming ancillary data is discarded.
In both of these cases, the
@@ -632,11 +634,11 @@ In both of these cases, the
flag will be set in the
.I msg.msg_flags
value returned by
-.BR recvmsg (2).
+.MR recvmsg 2 .
.\"
.SS Ioctls
The following
-.BR ioctl (2)
+.MR ioctl 2
calls return information in
.IR value .
The correct syntax is:
@@ -680,7 +682,7 @@ sockets,
the returned value is the same as
for Internet domain datagram sockets;
see
-.BR udp (7).
+.MR udp 7 .
.SH ERRORS
.TP
.B EADDRINUSE
@@ -689,7 +691,7 @@ object already exists.
.TP
.B EBADF
This error can occur for
-.BR sendmsg (2)
+.MR sendmsg 2
when sending a file descriptor as ancillary data over
a UNIX domain socket (see the description of
.BR SCM_RIGHTS ,
@@ -698,7 +700,7 @@ is being sent is not valid (e.g., it is not an open file descriptor).
.TP
.B ECONNREFUSED
The remote address specified by
-.BR connect (2)
+.MR connect 2
was not a listening socket.
This error can also occur if the target pathname is not a socket.
.TP
@@ -718,7 +720,7 @@ field of passed addresses, or the socket was in an
invalid state for the applied operation.
.TP
.B EISCONN
-.BR connect (2)
+.MR connect 2
called on an already connected socket or a target address was
specified on a connected socket.
.TP
@@ -727,7 +729,7 @@ The system-wide limit on the total number of open files has been reached.
.TP
.B ENOENT
The pathname in the remote address specified to
-.BR connect (2)
+.MR connect 2
did not exist.
.TP
.B ENOMEM
@@ -752,9 +754,9 @@ is sent as well.
This can be avoided by passing the
.B MSG_NOSIGNAL
flag to
-.BR send (2)
+.MR send 2
or
-.BR sendmsg (2).
+.MR sendmsg 2 .
.TP
.B EPROTONOSUPPORT
Passed protocol is not
@@ -776,7 +778,7 @@ the caller specified a PID that does not match any existing process.
.TP
.B ETOOMANYREFS
This error can occur for
-.BR sendmsg (2)
+.MR sendmsg 2
when sending a file descriptor as ancillary data over
a UNIX domain socket (see the description of
.BR SCM_RIGHTS ,
@@ -787,9 +789,9 @@ resource limit and the caller does not have the
.B CAP_SYS_RESOURCE
capability.
An in-flight file descriptor is one that has been sent using
-.BR sendmsg (2)
+.MR sendmsg 2
but has not yet been accepted in the recipient process using
-.BR recvmsg (2).
+.MR recvmsg 2 .
.IP
This error is diagnosed since mainline Linux 4.5
(and in some earlier kernel versions where the fix has been backported).
@@ -797,7 +799,7 @@ This error is diagnosed since mainline Linux 4.5
In earlier kernel versions,
it was possible to place an unlimited number of file descriptors in flight,
by sending each file descriptor with
-.BR sendmsg (2)
+.MR sendmsg 2
and then closing the file descriptor so that it was not accounted against the
.B RLIMIT_NOFILE
resource limit.
@@ -815,7 +817,7 @@ but the implementation details differ.)
Binding to a socket with a filename creates a socket
in the filesystem that must be deleted by the caller when it is no
longer needed (using
-.BR unlink (2)).
+.MR unlink 2 ).
The usual UNIX close-behind semantics apply; the socket can be unlinked
at any time and will be finally removed from the filesystem when the last
reference to it is closed.
@@ -824,9 +826,9 @@ To pass file descriptors or credentials over a
.B SOCK_STREAM
socket, you must
send or receive at least one byte of nonancillary data in the same
-.BR sendmsg (2)
+.MR sendmsg 2
or
-.BR recvmsg (2)
+.MR recvmsg 2
call.
.P
UNIX domain stream sockets do not support the notion of out-of-band data.
@@ -846,7 +848,7 @@ the pathname beyond
.IR sizeof(sun_path) .
Consequently, when retrieving the socket address
(for example, via
-.BR accept (2)),
+.MR accept 2 ),
.\" The behavior on Solaris is quite similar.
if the input
.I addrlen
@@ -1191,16 +1193,16 @@ main(int argc, char *argv[])
For examples of the use of
.BR SCM_RIGHTS ,
see
-.BR cmsg (3)
+.MR cmsg 3
and
-.BR seccomp_unotify (2).
+.MR seccomp_unotify 2 .
.SH SEE ALSO
-.BR recvmsg (2),
-.BR sendmsg (2),
-.BR socket (2),
-.BR socketpair (2),
-.BR cmsg (3),
-.BR capabilities (7),
-.BR credentials (7),
-.BR socket (7),
-.BR udp (7)
+.MR recvmsg 2 ,
+.MR sendmsg 2 ,
+.MR socket 2 ,
+.MR socketpair 2 ,
+.MR cmsg 3 ,
+.MR capabilities 7 ,
+.MR credentials 7 ,
+.MR socket 7 ,
+.MR udp 7