From: Ben Gras Date: Thu, 3 Nov 2005 16:58:10 +0000 (+0000) Subject: Let chmem return error code on failure X-Git-Tag: v3.1.2a~524 X-Git-Url: http://zhaoyanbai.com/repos/%22https:/www.google.com/jsapi/static/mdoc.3.html?a=commitdiff_plain;h=a9702cca3a99a2bf897796edb41b0d3b756aba59;p=minix.git Let chmem return error code on failure --- diff --git a/commands/simple/chmem.c b/commands/simple/chmem.c index 3eb00c6db..b6187b1f0 100755 --- a/commands/simple/chmem.c +++ b/commands/simple/chmem.c @@ -42,6 +42,7 @@ char *argv[]; struct exec exec; char cpu; long max; + int last_failed = 0, any_failed = 0; progname = argv[0]; if (argc < 3) usage(); @@ -58,6 +59,10 @@ char *argv[]; argv += 1; while (--argc) { + if(last_failed) any_failed = 1; + + /* Unless we reach the end of this loop, this one failed. */ + last_failed = 1; ++argv; if(fd != -1) close(fd); fd = open(*argv, O_RDWR); @@ -117,8 +122,11 @@ char *argv[]; } printf("%s: Stack+malloc area changed from %ld to %ld bytes.\n", *argv, olddynam, newdynam); + + /* This one didn't fail. */ + last_failed = 0; } - return(0); + return(any_failed || last_failed ? 1 : 0); } void error(s1, s2)