From: Ben Gras Date: Wed, 1 Jun 2005 09:31:14 +0000 (+0000) Subject: different way of dealing with fd's so chmem X-Git-Tag: v3.1.0~791 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/dnssec-revoke.html?a=commitdiff_plain;h=39a2fc72ddf8a54ed732380ee1f910f26ff5c848;p=minix.git different way of dealing with fd's so chmem doesn't fail due to file descriptor leaks --- diff --git a/commands/simple/chmem.c b/commands/simple/chmem.c index 07da64c0d..3eb00c6db 100755 --- a/commands/simple/chmem.c +++ b/commands/simple/chmem.c @@ -36,7 +36,7 @@ char *argv[]; */ char *p; - int fd, separate; + int fd = -1, separate; size_t s; long lsize, olddynam, newdynam, newtot, overflow; struct exec exec; @@ -59,6 +59,7 @@ char *argv[]; while (--argc) { ++argv; + if(fd != -1) close(fd); fd = open(*argv, O_RDWR); if (fd < 0) { error("can't open", *argv); @@ -116,7 +117,6 @@ char *argv[]; } printf("%s: Stack+malloc area changed from %ld to %ld bytes.\n", *argv, olddynam, newdynam); - close(fd); } return(0); }