From 0bde2e4ad9ef40c5a2f8d55a0d686f8c82ce6794 Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Tue, 9 Jan 2007 11:22:09 +0000 Subject: [PATCH] =?UTF-8?q?=20=20*=20Don=E2=80=99t=20report=20exit=20statu?= =?UTF-8?q?s=20by=20default.=20=20=20*=20Add=20-x/--check-exit=20to=20get?= =?UTF-8?q?=20back=20to=20the=20previous=20behaviour.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doc/zzuf.1 | 7 ++++++- src/zzuf.c | 21 ++++++++++++++------- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/doc/zzuf.1 b/doc/zzuf.1 index e05515a..4c5b013 100644 --- a/doc/zzuf.1 +++ b/doc/zzuf.1 @@ -60,7 +60,8 @@ specific files. Stop forking when at least \fIn\fR children have crashed. The default value is 1, meaning \fBzzuf\fR will stop as soon as one child has crashed. A process is considered to have crashed if any signal (such as, but not limited to, -\fBSIGSEGV\fR) caused it to exit. +\fBSIGSEGV\fR) caused it to exit. If the \fB\-x\fR flag is used, this will +also include processes that exit with a non-zero status. This option is only relevant if the \fB\-s\fR flag is used with an interval argument. @@ -188,6 +189,10 @@ Automatically terminate child processes that run for more than \fIn\fR seconds. This is useful to detect infinite loops or processes stuck in other situations. See also the \fB\-B\fR flag. .TP +\fB\-x\fR, \fB\-\-check\-exit\fR +Report processes that exit with a non-zero status. By default only processes +that crash due to a signal are reported. +.TP \fB\-h\fR, \fB\-\-help\fR Display a short help message and exit. .TP diff --git a/src/zzuf.c b/src/zzuf.c index c50a88c..27acb56 100644 --- a/src/zzuf.c +++ b/src/zzuf.c @@ -79,6 +79,7 @@ static int endseed = 1; static int quiet = 0; static int maxbytes = -1; static int md5 = 0; +static int checkexit = 0; static double maxtime = -1.0; #define ZZUF_FD_SET(fd, p_fdset, maxfd) \ @@ -126,14 +127,15 @@ int main(int argc, char *argv[]) { "seed", 1, NULL, 's' }, { "signal", 0, NULL, 'S' }, { "max-time", 1, NULL, 'T' }, + { "check-exit", 0, NULL, 'x' }, { "help", 0, NULL, 'h' }, { "version", 0, NULL, 'v' }, }; - int c = getopt_long(argc, argv, "B:cC:dE:F:iI:MnP:qr:R:s:ST:hv", + int c = getopt_long(argc, argv, "B:cC:dE:F:iI:MnP:qr:R:s:ST:xhv", long_options, &option_index); # else # define MOREINFO "Try `%s -h' for more information.\n" - int c = getopt(argc, argv, "B:cC:dE:F:iI:MnP:qr:R:s:ST:hv"); + int c = getopt(argc, argv, "B:cC:dE:F:iI:MnP:qr:R:s:ST:xhv"); # endif if(c == -1) break; @@ -206,6 +208,9 @@ int main(int argc, char *argv[]) case 'T': /* --max-time */ maxtime = atof(optarg); break; + case 'x': /* --check-exit */ + checkexit = 1; + break; case 'h': /* --help */ usage(); return 0; @@ -515,7 +520,7 @@ static void clean_children(void) if(pid <= 0) continue; - if(WIFEXITED(status) && WEXITSTATUS(status)) + if(checkexit && WIFEXITED(status) && WEXITSTATUS(status)) { fprintf(stdout, "zzuf[seed=%i]: exit %i\n", child_list[i].seed, WEXITSTATUS(status)); @@ -659,10 +664,10 @@ static void version(void) #if defined(HAVE_GETOPT_H) static void usage(void) { - printf("Usage: zzuf [-cdiMnqS] [-r ratio] [-s seed | -s start:stop]\n"); - printf(" [-F forks] [-C crashes] [-B bytes] [-T seconds]\n"); - printf(" [-P protect] [-R refuse]\n"); - printf(" [-I include] [-E exclude] [PROGRAM [ARGS]...]\n"); + printf("Usage: zzuf [-cdiMnqSx] [-r ratio] [-s seed | -s start:stop]\n"); + printf(" [-F forks] [-C crashes] [-B bytes] [-T seconds]\n"); + printf(" [-P protect] [-R refuse]\n"); + printf(" [-I include] [-E exclude] [PROGRAM [ARGS]...]\n"); # ifdef HAVE_GETOPT_LONG printf(" zzuf -h | --help\n"); printf(" zzuf -v | --version\n"); @@ -692,6 +697,7 @@ static void usage(void) printf(" --seed specify a seed range\n"); printf(" -S, --signal prevent children from diverting crashing signals\n"); printf(" -T, --max-time kill children that run for more than seconds\n"); + printf(" -x, --check-exit report processes that exit with a non-zero status\n"); printf(" -h, --help display this help and exit\n"); printf(" -v, --version output version information and exit\n"); # else @@ -713,6 +719,7 @@ static void usage(void) printf(" specify a seed range\n"); printf(" -S prevent children from diverting crashing signals\n"); printf(" -T kill children that run for more than seconds\n"); + printf(" -x report processes that exit with a non-zero status\n"); printf(" -h display this help and exit\n"); printf(" -v output version information and exit\n"); # endif