File: fdbuf.c

package info (click to toggle)
tra 20020816-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k, sarge
  • size: 1,696 kB
  • ctags: 2,623
  • sloc: ansic: 22,519; makefile: 406; asm: 269
file content (30 lines) | stat: -rw-r--r-- 362 bytes parent folder | download
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
#include "tra.h"

static int
fdbufhelp(void *a)
{
	Fdbuf *b;

	b = a;
	_fdbufwatch(b);
	_exits(nil);
	return 0;
}

Fdbuf*
openfdbuf(int fd)
{
	uchar *stk;
	Fdbuf *b;

	b = emalloc(sizeof(Fdbuf));
	b->fd = fd;
	stk = emalloc(8192);
	switch(clone(fdbufhelp, stk+8100, CLONE_FILES|CLONE_VM, b)){
	case -1:
		sysfatal("rfork fdbuf: %r");
	default:
		return b;
	}
}