lib9: add write function that withstands interrupts

This commit is contained in:
Russ Cox 2008-07-04 12:38:26 -04:00
parent fc9fc9c831
commit cab935a0ba
3 changed files with 26 additions and 0 deletions

View file

@ -157,6 +157,7 @@ LIB9OFILES=\
unsharp.$O\
wait.$O\
waitpid.$O\
write.$O\
OFILES=\
$LIB9OFILES\

23
src/lib9/write.c Normal file
View file

@ -0,0 +1,23 @@
#include <u.h>
#define NOPLAN9DEFINES
#include <libc.h>
long
p9write(int f, void *av, long n)
{
char *a;
long m, t;
a = av;
t = 0;
while(t < n){
m = write(f, a+t, n-t);
if(m <= 0){
if(t == 0)
return m;
break;
}
t += m;
}
return t;
}