From cab935a0ba34797d8b75fe1cfb7624a33d25e671 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Fri, 4 Jul 2008 12:38:26 -0400 Subject: lib9: add write function that withstands interrupts --- src/lib9/mkfile | 1 + src/lib9/write.c | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 src/lib9/write.c (limited to 'src/lib9') diff --git a/src/lib9/mkfile b/src/lib9/mkfile index ca615435..782dd274 100644 --- a/src/lib9/mkfile +++ b/src/lib9/mkfile @@ -157,6 +157,7 @@ LIB9OFILES=\ unsharp.$O\ wait.$O\ waitpid.$O\ + write.$O\ OFILES=\ $LIB9OFILES\ diff --git a/src/lib9/write.c b/src/lib9/write.c new file mode 100644 index 00000000..aa32db7f --- /dev/null +++ b/src/lib9/write.c @@ -0,0 +1,23 @@ +#include +#define NOPLAN9DEFINES +#include + +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; +} -- cgit v1.2.3