kgio.git  about / heads / tags
kinder, gentler I/O for Ruby
blob 2d9a13a245139a5a12bacb122688eb42449bb0eb 431 bytes (raw)
$ git show rbx-wip:ext/kgio/nonblock.h	# shows this blob on the CLI

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
 
#include <ruby.h>
#include <unistd.h>
#include <fcntl.h>
static void set_nonblocking(int fd)
{
	int flags = fcntl(fd, F_GETFL);

	/*
	 * do not check < 0 here, one day we may have enough FD flags
	 * to require negative bit
	 */
	if (flags == -1)
		rb_sys_fail("fcntl(F_GETFL)");
	if ((flags & O_NONBLOCK) == O_NONBLOCK)
		return;
	flags = fcntl(fd, F_SETFL, flags | O_NONBLOCK);
	if (flags < 0)
		rb_sys_fail("fcntl(F_SETFL)");
}

git clone git://yhbt.net/kgio.git
git clone https://yhbt.net/kgio.git