summaryrefslogtreecommitdiff
path: root/support/xaccept4.c
diff options
context:
space:
mode:
authorFlorian Weimer <fweimer@redhat.com>2017-04-19 07:44:48 +0200
committerFlorian Weimer <fweimer@redhat.com>2017-04-19 07:44:48 +0200
commite92030239abb4038d4f915d47021d6c037239309 (patch)
tree1c8c4877f35df78b7441a5736d8551b9b4877231 /support/xaccept4.c
parent62f71aad7e0d9df95578846134f1738ddf0e7844 (diff)
Assume that accept4 is always available and works
Simplify the Linux accept4 implementation based on the assumption that it is available in some way. __ASSUME_ACCEPT4_SOCKETCALL was previously unused, so remove it. For ia64, the accept4 system call (and socket call) were backported in kernel version 3.2.18. Reflect this in the installation instructions.
Diffstat (limited to 'support/xaccept4.c')
-rw-r--r--support/xaccept4.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/support/xaccept4.c b/support/xaccept4.c
new file mode 100644
index 0000000000..67dd95e9fb
--- /dev/null
+++ b/support/xaccept4.c
@@ -0,0 +1,32 @@
+/* accept4 with error checking.
+ Copyright (C) 2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <support/xsocket.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <support/check.h>
+
+int
+xaccept4 (int fd, struct sockaddr *sa, socklen_t *salen, int flags)
+{
+ int clientfd = accept4 (fd, sa, salen, flags);
+ if (clientfd < 0)
+ FAIL_EXIT1 ("accept4 (%d, 0x%x): %m", fd, flags);
+ return clientfd;
+}