19 #define STDIN_FILENO 0 20 #define STDOUT_FILENO 1 21 #define STDERR_FILENO 2 36 #include <sys/select.h> 44 inline ssize_t
read(
int fildes,
void *buf,
size_t nbyte)
46 ssize_t lBytesRead = 0;
50 const ssize_t lResult =
::read(fildes, buf, nbyte);
60 return (lBytesRead > 0) ? lBytesRead : -1;
62 else if (lResult == 0)
67 else if (lResult < nbyte)
70 lBytesRead += lResult;
71 buf =
reinterpret_cast<char*
>(buf) + lResult;
77 return lBytesRead + lResult;
82 inline ssize_t
write(
int fildes,
const void *buf,
size_t nbyte)
84 ssize_t lBytesWritten = 0;
88 const ssize_t lResult =
::write(fildes, buf, nbyte);
99 return (lBytesWritten > 0) ? lBytesWritten : -1;
101 else if (lResult < nbyte)
104 lBytesWritten += lResult;
105 buf =
reinterpret_cast<const char*
>(buf) + lResult;
111 return lBytesWritten + lResult;
120 const ssize_t lResult =
::fsync(fildes);
143 const ssize_t lResult =
::ftruncate(fildes, length);
164 const int RETRY = 10;
168 const ssize_t lResult =
::close(fildes);
192 inline int select(
int nfds, fd_set* readfds, fd_set* writefds, fd_set* errorfds,
struct timeval* timeout)
196 const int lResult =
mstr_select(nfds, readfds, writefds, errorfds, timeout);
215 inline int fchown(
int fildes, uid_t owner, gid_t group)
219 const int lResult =
::fchown(fildes, owner, group);
238 inline int dup(
int fildes)
242 const ssize_t lResult =
::dup(fildes);
260 inline int dup2(
int fildes,
int fildes2)
264 const ssize_t lResult =
::dup2(fildes, fildes2);
294 #endif // PDCunistd_h #define mstr_select(A, B, C, D, E)
Definition: PDCselect.h:54
int closesocket(int fildes)
Definition: PDCunistd.h:284