aboutsummaryrefslogtreecommitdiff
path: root/src/libthread/test/tspawnloop.c
blob: 8835267fe312ee8b85ae4afd6ef7e8c9c03c80ab (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
38
39
40
41
#include "u.h"
#include "libc.h"
#include "thread.h"

void
execproc(void *v)
{
	int i, fd[3];
	char buf[100], *args[3];

	i = (int)v;
	sprint(buf, "%d", i);
	fd[0] = dup(0, -1);
	fd[1] = dup(1, -1);
	fd[2] = dup(2, -1);
	args[0] = "echo";
	args[1] = buf;
	args[2] = nil;
	threadexec(nil, fd, args[0], args);
}
	
void
threadmain(int argc, char **argv)
{
	int i;
	Channel *c;
	Waitmsg *w;

	ARGBEGIN{
	case 'D':
		break;
	}ARGEND

	c = threadwaitchan();
	for(i=0;; i++){
		proccreate(execproc, (void*)i, 16384);
		w = recvp(c);
		if(w == nil)
			sysfatal("exec/recvp failed: %r");
	}
}