kitchen

kitchen - default: /* parent */ pids[npids++] = pid; break;...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
/* * kitchen.c * * Run a bunch of sinks (only). * * This tests concurrent read access to the console driver. */ #include <unistd.h> #include <err.h> static char *sargv[2] = { (char *)"sink", NULL }; #define MAXPROCS 6 static int pids[MAXPROCS], npids; static void sink(void) { int pid = fork(); switch (pid) { case -1: err(1, "fork"); case 0: /* child */ execv("/testbin/sink", sargv); err(1, "/testbin/sink");
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: default: /* parent */ pids[npids++] = pid; break; } } static void waitall(void) { int i, status; for (i=0; i&lt;npids; i++) { if (waitpid(pids[i], &amp;status, 0)&lt;0) { warn(&quot;waitpid for %d&quot;, pids[i]); } else if (status != 0) { warnx(&quot;pid %d: exit %d&quot;, pids[i], status); } } } int main(void) { sink(); sink(); sink(); sink(); waitall(); return 0; }...
View Full Document

Page1 / 2

kitchen - default: /* parent */ pids[npids++] = pid; break;...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online