9base

revived minimalist port of Plan 9 userland to Unix
git clone git://git.suckless.org/9base
Log | Files | Refs | README | LICENSE

write.c (260B)


      1 #include <u.h>
      2 #define NOPLAN9DEFINES
      3 #include <libc.h>
      4 
      5 long
      6 p9write(int f, void *av, long n)
      7 {
      8 	char *a;
      9 	long m, t;
     10 
     11 	a = av;
     12 	t = 0;
     13 	while(t < n){
     14 		m = write(f, a+t, n-t);
     15 		if(m <= 0){
     16 			if(t == 0)
     17 				return m;
     18 			break;
     19 		}
     20 		t += m;
     21 	}
     22 	return t;
     23 }