If you cp many files the system can run out of something
authorKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Wed, 17 Nov 1993 04:20:14 +0000 (20:20 -0800)
committerKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Wed, 17 Nov 1993 04:20:14 +0000 (20:20 -0800)
(I haven't investigated exactly what).  The problem is
that cp mmaps the source file, but it's never unmapped.
From: Lennart Augustsson <augustss@cs.chalmers.se>

SCCS-vsn: bin/cp/utils.c 8.2

usr/src/bin/cp/utils.c

index 855c5de..bdd80ee 100644 (file)
@@ -6,7 +6,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)utils.c    8.1 (Berkeley) %G%";
+static char sccsid[] = "@(#)utils.c    8.2 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <sys/param.h>
 #endif /* not lint */
 
 #include <sys/param.h>
@@ -86,6 +86,9 @@ copy_file(entp, dne)
                        err("%s: %s", entp->fts_path, strerror(errno));
                if (write(to_fd, p, fs->st_size) != fs->st_size)
                        err("%s: %s", to.p_path, strerror(errno));
                        err("%s: %s", entp->fts_path, strerror(errno));
                if (write(to_fd, p, fs->st_size) != fs->st_size)
                        err("%s: %s", to.p_path, strerror(errno));
+               /* Some systems don't unmap on close(2). */
+               if (munmap(p, fs->st_size) < 0)
+                       err("%s: %s", entp->fts_path, strerror(errno));
        } else
 #endif
        {
        } else
 #endif
        {