Changeset 1660 for zzuf/trunk/src/zzuf.c
- Timestamp:
- Jan 13, 2007, 11:50:38 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
zzuf/trunk/src/zzuf.c
r1659 r1660 88 88 static int maxmem = -1; 89 89 static int64_t maxtime = -1; 90 static int64_t delay = 0; 90 91 static int64_t lastlaunch = 0; 91 92 … … 111 112 for(;;) 112 113 { 114 # define OPTSTR "B:cC:dD:E:F:iI:mM:nP:qr:R:s:ST:xhv" 113 115 # ifdef HAVE_GETOPT_LONG 114 116 # define MOREINFO "Try `%s --help' for more information.\n" … … 121 123 { "max-crashes", 1, NULL, 'C' }, 122 124 { "debug", 0, NULL, 'd' }, 125 { "delay", 1, NULL, 'D' }, 123 126 { "exclude", 1, NULL, 'E' }, 124 127 { "max-forks", 1, NULL, 'F' }, … … 139 142 { "version", 0, NULL, 'v' }, 140 143 }; 141 int c = getopt_long(argc, argv, "B:cC:dE:F:iI:mM:nP:qr:R:s:ST:xhv", 142 long_options, &option_index); 144 int c = getopt_long(argc, argv, OPTSTR, long_options, &option_index); 143 145 # else 144 146 # define MOREINFO "Try `%s -h' for more information.\n" 145 int c = getopt(argc, argv, "B:cC:dE:F:iI:mM:nP:qr:R:s:ST:xhv");147 int c = getopt(argc, argv, OPTSTR); 146 148 # endif 147 149 if(c == -1) … … 163 165 case 'd': /* --debug */ 164 166 setenv("ZZUF_DEBUG", "1", 1); 167 break; 168 case 'D': /* --delay */ 169 delay = (int64_t)(atof(optarg) * 1000000.0); 165 170 break; 166 171 case 'E': /* --exclude */ … … 422 427 char buf[BUFSIZ]; 423 428 int fd[3][2]; 429 int64_t now = _zz_time(); 424 430 pid_t pid; 425 431 int i, j; … … 433 439 if(maxcrashes && crashes >= maxcrashes) 434 440 return; /* all jobs crashed */ 441 442 if(delay > 0 && lastlaunch + delay > now) 443 return; /* too early */ 435 444 436 445 /* Find the empty slot */ … … 484 493 } 485 494 486 lastlaunch = _zz_time();487 488 495 /* We’re the parent, acknowledge spawn */ 489 child_list[i].date = lastlaunch;496 child_list[i].date = now; 490 497 child_list[i].pid = pid; 491 498 for(j = 0; j < 3; j++) … … 500 507 child_list[i].ctx = _zz_md5_init(); 501 508 509 lastlaunch = now; 502 510 child_count++; 503 511 seed++; … … 712 720 { 713 721 printf("Usage: zzuf [-cdimnqSx] [-r ratio] [-s seed | -s start:stop]\n"); 714 printf(" [- F forks] [-C crashes] [-B bytes] [-T seconds]\n");715 printf(" [- M bytes] [-P protect] [-R refuse]\n");722 printf(" [-D delay] [-F forks] [-C crashes] [-B bytes]\n"); 723 printf(" [-T seconds] [-M bytes] [-P protect] [-R refuse]\n"); 716 724 printf(" [-I include] [-E exclude] [PROGRAM [--] [ARGS]...]\n"); 717 725 # ifdef HAVE_GETOPT_LONG … … 730 738 printf(" -C, --max-crashes <n> stop after <n> children have crashed (default 1)\n"); 731 739 printf(" -d, --debug print debug messages\n"); 740 printf(" -D, --delay delay between forks\n"); 732 741 printf(" -E, --exclude <regex> do not fuzz files matching <regex>\n"); 733 742 printf(" -F, --max-forks <n> number of concurrent children (default 1)\n"); … … 753 762 printf(" -C <n> stop after <n> children have crashed (default 1)\n"); 754 763 printf(" -d print debug messages\n"); 764 printf(" -D delay between forks\n"); 755 765 printf(" -E <regex> do not fuzz files matching <regex>\n"); 756 766 printf(" -F <n> number of concurrent forks (default 1)\n");
Note: See TracChangeset
for help on using the changeset viewer.