repeat.c - vx32 - Local 9vx git repository for patches.
 (HTM) git clone git://r-36.net/vx32
 (DIR) Log
 (DIR) Files
 (DIR) Refs
       ---
       repeat.c (487B)
       ---
            1 
            2 #include <stdio.h>
            3 #include <stdlib.h>
            4 #include <string.h>
            5 #include <unistd.h>
            6 #include <assert.h>
            7 
            8 int main(int argc, char **argv)
            9 {
           10         assert(argc >= 3);        // yeah, really user-friendly...
           11 
           12         int reps = atoi(argv[1]);
           13         assert(reps >= 1);
           14 
           15         for (int i = 0; i < reps; i++) {
           16                 pid_t pid = vfork();
           17                 if (pid == 0) {        // in the child
           18                         execv(argv[2], &argv[2]);
           19                         perror("exec");
           20                         abort();
           21                 }
           22                 if (pid < 0) {
           23                         perror("vfork");
           24                         abort();
           25                 }
           26                 waitpid(pid, NULL, 0);
           27         }
           28         return 0;
           29 }
           30