os161-1.99
 All Data Structures
hogparty.c
00001 /*
00002  * hogparty
00003  *
00004  *      create some talking hogs
00005  *
00006  *   relies on fork, _exit, stdout and stderr, and execv
00007  *
00008  */
00009 
00010 #include <unistd.h>
00011 #include <err.h>
00012 
00013 static char *xhargv[2] = { (char *)"xhog", NULL };
00014 static char *yhargv[2] = { (char *)"yhog", NULL };
00015 static char *zhargv[2] = { (char *)"zhog", NULL };
00016 
00017 static
00018 void
00019 spawnv(const char *prog, char **argv)
00020 {
00021   pid_t pid = fork();
00022   switch (pid) {
00023   case -1:
00024     err(1, "fork");
00025   case 0:
00026     /* child */
00027     execv(prog, argv);
00028     err(1, "%s", prog);
00029   default:
00030     /* parent */
00031     break;
00032   }
00033 }
00034 
00035 int
00036 main()
00037 {
00038   spawnv("/uw-testbin/xhog", xhargv);
00039   spawnv("/uw-testbin/yhog", yhargv);
00040   spawnv("/uw-testbin/zhog", zhargv);
00041   return 0;
00042 }
 All Data Structures