/*
* call-seq:
*
* Kgio.accept_cloexec = true
* Kgio.accept_cloexec = false
*
* Sets whether or not Kgio::Socket objects created by
* TCPServer#kgio_accept,
* TCPServer#kgio_tryaccept,
* UNIXServer#kgio_accept,
* and UNIXServer#kgio_tryaccept
* default to being created with the FD_CLOEXEC file descriptor flag.
*
* This is on by default, as there is little reason to deal to enable
* it for client sockets on a socket server.
*/
static VALUE set_cloexec(VALUE mod, VALUE boolean)
{
switch (TYPE(boolean)) {
case T_TRUE:
accept4_flags |= SOCK_CLOEXEC;
return boolean;
case T_FALSE:
accept4_flags &= ~SOCK_CLOEXEC;
return boolean;
}
rb_raise(rb_eTypeError, "not true or false");
return Qnil;
}