2 * Copyright 2001, 2002, 2003 David Mansfield and Cobite, Inc.
3 * See COPYING file for license information
19 RCSID("$Id: sio.c,v 1.5 2001/10/25 18:36:11 adam Exp $");
21 ssize_t
readn(int fd
, void *buf
, size_t len
)
30 nread
= read(fd
,buf
,nleft
);
32 /* there is an issue which EINTR which could leave us a bit haywire
33 * if we get a signal after having read some bytes. special handling
34 * N.B: we *do* return EINTR if no data has been read yet (thanks Karl)
38 if (errno
== EINTR
&& nleft
!= (int)len
)
49 buf
= ((char *)buf
) + nread
;
54 ssize_t
writen(int fd
, const void *buf
, size_t len
)
63 nwritten
= write(fd
,buf
,nleft
);
65 /* there is an issue with EINTR if we have already written
66 a few bytes! return if we have not written any yet */
67 if (nwritten
< 0 && errno
== EINTR
)
69 if (nleft
== (int)len
)
82 buf
= ((char *)buf
) + nwritten
;