repo.or.cz
/
kgio.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
blame
|
history
|
raw
|
HEAD
make timed kgio_wait_* implementation safer
[kgio.git]
/
ext
/
kgio
/
nonblock.h
blob
43de8cd98f7fb58b05e5ac67186f48f3fdf4773c
1
#include <ruby.h>
2
#include <unistd.h>
3
#include <fcntl.h>
4
static void
set_nonblocking
(
int
fd
)
5
{
6
int
flags
=
fcntl
(
fd
,
F_GETFL
);
7
8
if
(
flags
== -
1
)
9
rb_sys_fail
(
"fcntl(F_GETFL)"
);
10
if
((
flags
&
O_NONBLOCK
) ==
O_NONBLOCK
)
11
return
;
12
flags
=
fcntl
(
fd
,
F_SETFL
,
flags
|
O_NONBLOCK
);
13
if
(
flags
== -
1
)
14
rb_sys_fail
(
"fcntl(F_SETFL)"
);
15
}