landlock_restrict_self.2: tfix
[man-pages.git] / man2 / shutdown.2
blobe23b2e258c2c437a1da80fc2db23b0f560337819
1 .\" Copyright (c) 1983, 1991 The Regents of the University of California.
2 .\" All rights reserved.
3 .\"
4 .\" SPDX-License-Identifier: BSD-4-Clause-UC
5 .\"
6 .\"     $Id: shutdown.2,v 1.1.1.1 1999/03/21 22:52:23 freitag Exp $
7 .\"
8 .\" Modified Sat Jul 24 09:57:55 1993 by Rik Faith <faith@cs.unc.edu>
9 .\" Modified Tue Oct 22 22:04:51 1996 by Eric S. Raymond <esr@thyrsus.com>
10 .\" Modified 1998 by Andi Kleen
11 .\"
12 .TH SHUTDOWN 2 2021-03-22 "Linux" "Linux Programmer's Manual"
13 .SH NAME
14 shutdown \- shut down part of a full-duplex connection
15 .SH LIBRARY
16 Standard C library
17 .RI ( libc ", " \-lc )
18 .SH SYNOPSIS
19 .nf
20 .B #include <sys/socket.h>
21 .PP
22 .BI "int shutdown(int " sockfd ", int " how );
23 .fi
24 .SH DESCRIPTION
25 The
26 .BR shutdown ()
27 call causes all or part of a full-duplex connection on the socket
28 associated with
29 .I sockfd
30 to be shut down.
32 .I how
34 .BR SHUT_RD ,
35 further receptions will be disallowed.
37 .I how
39 .BR SHUT_WR ,
40 further transmissions will be disallowed.
42 .I how
44 .BR SHUT_RDWR ,
45 further receptions and transmissions will be disallowed.
46 .SH RETURN VALUE
47 On success, zero is returned.
48 On error, \-1 is returned, and
49 .I errno
50 is set to indicate the error.
51 .SH ERRORS
52 .TP
53 .B EBADF
54 .I sockfd
55 is not a valid file descriptor.
56 .TP
57 .B EINVAL
58 An invalid value was specified in
59 .I how
60 (but see BUGS).
61 .TP
62 .B ENOTCONN
63 The specified socket is not connected.
64 .TP
65 .B ENOTSOCK
66 The file descriptor
67 .I sockfd
68 does not refer to a socket.
69 .SH STANDARDS
70 POSIX.1-2001, POSIX.1-2008, 4.4BSD
71 .RB ( shutdown ()
72 first appeared in 4.2BSD).
73 .SH NOTES
74 The constants
75 .BR SHUT_RD ,
76 .BR SHUT_WR ,
77 .B SHUT_RDWR
78 have the value 0, 1, 2,
79 respectively, and are defined in
80 .I <sys/socket.h>
81 since glibc-2.1.91.
82 .SH BUGS
83 Checks for the validity of
84 .I how
85 are done in domain-specific code,
86 and before Linux 3.7 not all domains performed these checks.
87 .\" https://bugzilla.kernel.org/show_bug.cgi?id=47111
88 Most notably, UNIX domain sockets simply ignored invalid values.
89 This problem was fixed for UNIX domain sockets
90 .\" commit fc61b928dc4d72176cf4bd4d30bf1d22e599aefc
91 .\" and for DECnet sockets in commit 46b66d7077b89fb4917ceef19b3f7dd86055c94a
92 in Linux 3.7.
93 .SH SEE ALSO
94 .BR close (2),
95 .BR connect (2),
96 .BR socket (2),
97 .BR socket (7)