aboutsummaryrefslogtreecommitdiff
path: root/src/lib9/postnote.c
blob: d750c69dc68ba3543fa1210da3dcb39018df2746 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include <u.h>
#define NOPLAN9DEFINES
#include <libc.h>

#include <signal.h>


extern int _p9strsig(char*);

int
postnote(int who, int pid, char *msg)
{
	int sig;

	sig = _p9strsig(msg);
	if(sig == 0){
		werrstr("unknown note");
		return -1;
	}

	if(pid <= 0){
		werrstr("bad pid in postnote");
		return -1;
	}

	switch(who){
	default:
		werrstr("bad who in postnote");
		return -1;
	case PNPROC:
		return kill(pid, sig);
	case PNGROUP:
		if((pid = getpgid(pid)) < 0)
			return -1;
		return killpg(pid, sig);
	}
}