etc/services - sync with NetBSD-8
[minix.git] / minix / lib / libsys / closenb.c
blob5603708cc15b06a06e3c34175e84dd6d3ee114af
1 #include "syslib.h"
3 #include <string.h>
5 /*
6 * Non-blocking variant of close(2). This call is to be used by system
7 * services that need to close arbitrary local file descriptors. The purpose
8 * of the call is to avoid that such services end up blocking on closing socket
9 * file descriptors with the SO_LINGER socket option enabled. They cannot put
10 * the file pointer in non-blocking mode to that end, because the file pointer
11 * may be shared with other processes.
13 * Even though this call is defined for system services only, there is no harm
14 * in letting arbitrary user processes use this functionality. Thus, it needs
15 * no separate VFS call number.
17 int
18 closenb(int fd)
20 message m;
22 memset(&m, 0, sizeof(m));
23 m.m_lc_vfs_close.fd = fd;
24 m.m_lc_vfs_close.nblock = 1;
26 return _taskcall(VFS_PROC_NR, VFS_CLOSE, &m);