main: Temporary fix assertion error

This variant uses `fdopen()` which is not standard, but it fixes problem on my 
system. In next commit `scriptin` will use `FileDescriptor*` from os/fileio in 
place of `FILE*`.
This commit is contained in:
ZyX
2017-03-19 16:09:48 +03:00
parent d2268d5ebb
commit fdfa1ed578
4 changed files with 90 additions and 1 deletions

View File

@@ -430,6 +430,29 @@ int os_close(const int fd)
return r;
}
/// Duplicate file descriptor
///
/// @param[in] fd File descriptor to duplicate.
///
/// @return New file descriptor or libuv error code (< 0).
int os_dup(const int fd)
FUNC_ATTR_WARN_UNUSED_RESULT
{
int ret;
os_dup_dup:
ret = dup(fd);
if (ret < 0) {
const int error = os_translate_sys_error(errno);
errno = 0;
if (error == UV_EINTR) {
goto os_dup_dup;
} else {
return error;
}
}
return ret;
}
/// Read from a file
///
/// Handles EINTR and ENOMEM, but not other errors.