Changeset 1801 for zzuf/trunk
- Timestamp:
- Jul 10, 2007, 5:23:18 PM (16 years ago)
- Location:
- zzuf/trunk/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
zzuf/trunk/src/opts.c
r1791 r1801 46 46 opts->maxmem = -1; 47 47 opts->maxtime = -1; 48 opts->maxcpu = -1; 48 49 opts->delay = 0; 49 50 opts->lastlaunch = 0; -
zzuf/trunk/src/opts.h
r1791 r1801 28 28 int quiet; 29 29 int maxbytes; 30 int maxcpu; 30 31 int md5; 31 32 int checkexit; -
zzuf/trunk/src/zzuf.c
r1800 r1801 163 163 # define OPTSTR_RLIMIT_MEM "" 164 164 #endif 165 #define OPTSTR OPTSTR_REGEX OPTSTR_RLIMIT_MEM \ 166 "Ab:B:C:dD:f:F:imnp:P:qr:R:s:St:vxhV" 165 #if defined HAVE_SETRLIMIT && defined ZZUF_RLIMIT_CPU 166 # define OPTSTR_RLIMIT_CPU "T:" 167 #else 168 # define OPTSTR_RLIMIT_CPU "" 169 #endif 170 #define OPTSTR OPTSTR_REGEX OPTSTR_RLIMIT_MEM OPTSTR_RLIMIT_CPU \ 171 "Ab:B:C:dD:f:F:imnp:P:qr:R:s:St:vxhV" 167 172 #define MOREINFO "Try `%s --help' for more information.\n" 168 173 int option_index = 0; … … 199 204 { "signal", 0, NULL, 'S' }, 200 205 { "max-time", 1, NULL, 't' }, 206 { "max-cpu", 1, NULL, 'T' }, 201 207 { "verbose", 0, NULL, 'v' }, 202 208 { "check-exit", 0, NULL, 'x' }, … … 310 316 opts->maxtime = (int64_t)(atof(myoptarg) * 1000000.0); 311 317 break; 318 #if defined HAVE_SETRLIMIT && defined ZZUF_RLIMIT_CPU 319 case 'T': /* --max-cpu */ 320 opts->maxcpu = (int)(atof(myoptarg) + 0.5); 321 break; 322 #endif 312 323 case 'x': /* --check-exit */ 313 324 opts->checkexit = 1; … … 706 717 && opts->child[i].status == STATUS_SIGTERM)) 707 718 { 719 char const *message = ""; 720 721 if(WTERMSIG(status) == SIGKILL && opts->maxmem >= 0) 722 message = " (memory exceeded?)"; 723 # if defined SIGXCPU 724 else if(WTERMSIG(status) == SIGXCPU && opts->maxcpu >= 0) 725 message = " (CPU time exceeded?)"; 726 # endif 727 else if(WTERMSIG(status) == SIGKILL && opts->maxcpu >= 0) 728 message = " (CPU time exceeded?)"; 729 708 730 finfo(stderr, opts, opts->child[i].seed); 709 731 fprintf(stderr, "signal %i%s%s\n", 710 WTERMSIG(status), sig2str(WTERMSIG(status)), 711 (WTERMSIG(status) == SIGKILL && opts->maxmem >= 0) ? 712 " (memory exceeded?)" : ""); 732 WTERMSIG(status), sig2str(WTERMSIG(status)), message); 713 733 opts->crashes++; 714 734 } … … 907 927 #endif 908 928 929 #if defined HAVE_SETRLIMIT && defined ZZUF_RLIMIT_CPU 930 if(opts->maxcpu >= 0) 931 { 932 struct rlimit rlim; 933 rlim.rlim_cur = opts->maxcpu; 934 rlim.rlim_max = opts->maxcpu + 5; 935 setrlimit(ZZUF_RLIMIT_CPU, &rlim); 936 } 937 #endif 938 909 939 /* Set environment variables */ 910 940 sprintf(buf, "%i", opts->seed); … … 1110 1140 #endif 1111 1141 printf(" [-f fuzzing] [-D delay] [-F forks] [-C crashes] [-B bytes]\n"); 1142 printf(" [-t seconds] "); 1143 #if defined HAVE_SETRLIMIT && defined ZZUF_RLIMIT_CPU 1144 printf( "[-T seconds] "); 1145 #endif 1112 1146 #if defined HAVE_SETRLIMIT && defined ZZUF_RLIMIT_MEM 1113 printf(" [-t seconds] [-M bytes] [-b ranges] [-P protect] [-R refuse]\n"); 1114 #else 1115 printf(" [-t seconds] [-b ranges] [-P protect] [-R refuse]\n"); 1116 #endif 1117 #if defined HAVE_REGEX_H 1118 printf(" [-p descriptors] [-I include] [-E exclude]\n"); 1119 printf(" [PROGRAM [--] [ARGS]...]\n"); 1120 #else 1121 printf(" [-I include] [-E exclude] [PROGRAM [--] [ARGS]...]\n"); 1122 #endif 1147 printf( "[-M bytes] "); 1148 #endif 1149 printf( "[-b ranges] [-P protect]\n"); 1150 printf(" [-R refuse] [-p descriptors] "); 1151 #if defined HAVE_REGEX_H 1152 printf( "[-I include] [-E exclude]\n"); 1153 printf(" "); 1154 #endif 1155 printf( "[PROGRAM [--] [ARGS]...]\n"); 1123 1156 printf(" zzuf -h | --help\n"); 1124 1157 printf(" zzuf -V | --version\n"); … … 1159 1192 printf(" -S, --signal prevent children from diverting crashing signals\n"); 1160 1193 printf(" -t, --max-time <n> kill children that run for more than <n> seconds\n"); 1194 printf(" -T, --max-cpu <n> kill children that use more than <n> CPU seconds\n"); 1161 1195 printf(" -v, --verbose print information during the run\n"); 1162 1196 printf(" -x, --check-exit report processes that exit with a non-zero status\n");
Note: See TracChangeset
for help on using the changeset viewer.