aboutsummaryrefslogtreecommitdiff
path: root/src/libthread/test/tspawn.c
blob: ed4df3c491c6e2fbc8af61eac7259fc2f776bc5b (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
#include "u.h"
#include "libc.h"
#include "thread.h"

void
threadmain(int argc, char **argv)
{
	int fd[3];
	Channel *c;
	Waitmsg *w;

	ARGBEGIN{
	case 'D':
		break;
	}ARGEND

	c = threadwaitchan();
	fd[0] = dup(0, -1);
	fd[1] = dup(1, -1);
	fd[2] = dup(2, -1);
	if(threadspawn(fd, argv[0], argv) < 0)
		sysfatal("threadspawn: %r");
	fd[0] = dup(0, -1);
	fd[1] = dup(1, -1);
	fd[2] = dup(2, -1);
	if(threadspawn(fd, argv[0], argv) < 0)
		sysfatal("threadspawn: %r");
	w = recvp(c);
	if(w == nil)
		print("exec/recvp failed: %r\n");
	else
		print("%d %lud %lud %lud %s\n", w->pid, w->time[0], w->time[1], w->time[2], w->msg);
	w = recvp(c);
	if(w == nil)
		print("exec/recvp failed: %r\n");
	else
		print("%d %lud %lud %lud %s\n", w->pid, w->time[0], w->time[1], w->time[2], w->msg);
	threadexits(nil);
}