diff options
author | Russ Cox <rsc@swtch.com> | 2008-07-04 12:38:26 -0400 |
---|---|---|
committer | Russ Cox <rsc@swtch.com> | 2008-07-04 12:38:26 -0400 |
commit | cab935a0ba34797d8b75fe1cfb7624a33d25e671 (patch) | |
tree | 3dd76e00d49cc4375d015f6f730059a3fa3f11c2 /src | |
parent | fc9fc9c83154ff0fa5a56854ee1f023c78f66fd8 (diff) | |
download | plan9port-cab935a0ba34797d8b75fe1cfb7624a33d25e671.tar.gz plan9port-cab935a0ba34797d8b75fe1cfb7624a33d25e671.tar.bz2 plan9port-cab935a0ba34797d8b75fe1cfb7624a33d25e671.zip |
lib9: add write function that withstands interrupts
Diffstat (limited to 'src')
-rw-r--r-- | src/lib9/mkfile | 1 | ||||
-rw-r--r-- | src/lib9/write.c | 23 |
2 files changed, 24 insertions, 0 deletions
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 <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; +} |