~mcf/drawterm

ref: d28c5f37cfbd0507796d76ced17ad01fd11ea564 drawterm/libc/getpid.c -rw-r--r-- 198 bytes
d28c5f37 add preliminary riscv64 support from archlinux (thanks Sören Tempel) 7 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include	<u.h>
#include	<libc.h>

int
getpid(void)
{
	char b[20];
	int f;

	memset(b, 0, sizeof(b));
	f = open("#c/pid", 0);
	if(f >= 0) {
		read(f, b, sizeof(b));
		close(f);
	}
	return atol(b);
}