1 #include <u.h> 2 #include <libc.h> 3 4 int 5 postnote(int group, int pid, char *note) 6 { 7 char file[128]; 8 int f, r; 9 10 switch(group) { 11 case PNPROC: 12 sprint(file, "/proc/%d/note", pid); 13 break; 14 case PNGROUP: 15 sprint(file, "/proc/%d/notepg", pid); 16 break; 17 default: 18 return -1; 19 } 20 21 f = open(file, OWRITE); 22 if(f < 0) 23 return -1; 24 25 r = strlen(note); 26 if(write(f, note, r) != r) { 27 close(f); 28 return -1; 29 } 30 close(f); 31 return 0; 32 } 33