4 #include <msp/core/systemerror.h>
6 #include "handle_private.h"
13 void sys_set_blocking(Handle &handle, bool b)
15 int flags = fcntl(*handle, F_GETFL);
16 fcntl(*handle, F_SETFL, (flags&~O_NONBLOCK)|(b?0:O_NONBLOCK));
19 void sys_set_inherit(Handle &handle, bool i)
21 int flags = fcntl(*handle, F_GETFD);
22 fcntl(*handle, F_SETFD, (flags&~O_CLOEXEC)|(i?O_CLOEXEC:0));
25 size_t sys_read(Handle &handle, char *buf, size_t size)
27 ssize_t ret = read(*handle, buf, size);
33 throw system_error("read");
39 size_t sys_write(Handle &handle, const char *buf, size_t size)
41 ssize_t ret = write(*handle, buf, size);
47 throw system_error("write");
53 void sys_close(Handle &handle)
58 *handle = INVALID_HANDLE_VALUE;