diff --git a/ext/socket/init.c b/ext/socket/init.c index bd069263c6..bc01217641 100644 --- a/ext/socket/init.c +++ b/ext/socket/init.c @@ -61,8 +61,10 @@ rsock_init_sock(VALUE sock, int fd) { rb_io_t *fp; - if (!is_socket(fd)) - rb_raise(rb_eArgError, "not a socket file descriptor"); + if (!is_socket(fd)) { + errno = EBADF; + rb_sys_fail("not a socket file descriptor"); + } rb_update_max_fd(fd); MakeOpenFile(sock, fp);