1
  
2
  
3
  
4
  
5
  
6
  
7
  
8
  
9
  
10
  
11
  
12
  
13
  
14
  
15
  
16
  
17
  
18
  
19
  
20
  
21
  
22
  
23
  
24
  
25
  
26
  
27
  
28
  
29
  
30
  
31
  
32
  
33
  
34
  
35
  
36
  
37
  
38
  
39
  
40
  
41
  
42
  
43
  
44
  
45
  
46
  
47
  
48
  
49
  
50
  
51
  
52
  
53
  
54
  
55
  
56
  
57
  
58
  
59
  
/* 
|| This file is part of Pike. For copyright information see COPYRIGHT. 
|| Pike is distributed under GPL, LGPL and MPL. See the file COPYING 
|| for more information. 
*/ 
 
#ifndef FD_CONTROL_H 
#define FD_CONTROL_H 
 
#ifndef HAVE_ACCEPT4 
#ifdef HAVE_SYS_SOCKET_H 
#include <sys/socket.h> 
#endif 
 
/* NB: The default values are compatible with Linux, 
 *     but should work on other OSs as well, since 
 *     accept4(2) is emulated by us anyway. 
 */ 
#if !defined(SOCK_NONBLOCK) || !defined(SOCK_CLOEXEC) 
enum pike_sock_flags { 
#ifndef SOCK_CLOEXEC 
#if !defined(SOCK_NONBLOCK) || (SOCK_NONBLOCK != 0x80000) 
  SOCK_CLOEXEC = 0x80000, 
#else 
  /* Unlikely, but... */ 
  SOCK_CLOEXEC = 0x40000, 
#endif /* !SOCK_NONBLOCK || SOCK_NONBLOCK != 0x80000 */ 
#define SOCK_CLOEXEC  SOCK_CLOEXEC 
#endif 
#ifndef SOCK_NONBLOCK 
#if (SOCK_CLOEXEC != 0x00800) 
  SOCK_NONBLOCK = 0x00800, 
#else 
  /* Unlikely, but... */ 
  SOCK_NONBLOCK = 0x00400, 
#endif 
#define SOCK_NONBLOCK SOCK_NONBLOCK 
#endif 
}; 
#endif /* !SOCK_NONBLOCK || !SOCK_CLOEXEC */ 
#endif /* !HAVE_ACCEPT4 */ 
 
/* Prototypes begin here */ 
PMOD_EXPORT int set_nonblocking(int fd,int which); 
PMOD_EXPORT int query_nonblocking(int fd); 
PMOD_EXPORT int set_close_on_exec(int fd, int which); 
 
#ifdef HAVE_BROKEN_F_SETFD 
void do_close_on_exec(void); 
void cleanup_close_on_exec(void); 
#endif /* HAVE_BROKEN_F_SETFD */ 
#ifndef HAVE_ACCEPT4 
int accept4(int fd, struct sockaddr *addr, ACCEPT_SIZE_T *addrlen, int flags); 
#endif /* !HAVE_ACCEPT4 */ 
/* Prototypes end here */ 
 
#endif