9base

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

postnote.c (452B)


      1 #include <u.h>
      2 #define NOPLAN9DEFINES
      3 #include <libc.h>
      4 
      5 #include <signal.h>
      6 
      7 
      8 extern int _p9strsig(char*);
      9 
     10 int
     11 postnote(int who, int pid, char *msg)
     12 {
     13 	int sig;
     14 
     15 	sig = _p9strsig(msg);
     16 	if(sig == 0){
     17 		werrstr("unknown note");
     18 		return -1;
     19 	}
     20 
     21 	switch(who){
     22 	default:
     23 		werrstr("bad who in postnote");
     24 		return -1;
     25 	case PNPROC:
     26 		return kill(pid, sig);
     27 	case PNGROUP:
     28 		if((pid = getpgid(pid)) < 0)
     29 			return -1;
     30 		return killpg(pid, sig);
     31 	}
     32 }
     33 
     34