aboutsummaryrefslogtreecommitdiff
path: root/src/libthread/test/tspawnloop.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/libthread/test/tspawnloop.c')
-rw-r--r--src/libthread/test/tspawnloop.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/libthread/test/tspawnloop.c b/src/libthread/test/tspawnloop.c
new file mode 100644
index 00000000..8835267f
--- /dev/null
+++ b/src/libthread/test/tspawnloop.c
@@ -0,0 +1,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");
+ }
+}