1 #include "syslib.h" 2 3 #include <string.h> 4 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. 12 * 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. 16 */ 17 int 18 closenb(int fd) 19 { 20 message m; 21 22 memset(&m, 0, sizeof(m)); 23 m.m_lc_vfs_close.fd = fd; 24 m.m_lc_vfs_close.nblock = 1; 25 26 return _taskcall(VFS_PROC_NR, VFS_CLOSE, &m); 27 } 28