changeset 45822:61d63a774490

merge with stable
author Augie Fackler <augie@google.com>
date Sat, 07 Nov 2020 15:02:53 -0500
parents c2837640aeb0 (current diff) 8711dc13474c (diff)
children 793976f9029c
files
diffstat 2 files changed, 27 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/contrib/chg/chg.c	Mon Oct 05 19:46:31 2020 -0700
+++ b/contrib/chg/chg.c	Sat Nov 07 15:02:53 2020 -0500
@@ -8,6 +8,7 @@
  */
 
 #include <assert.h>
+#include <dirent.h>
 #include <errno.h>
 #include <fcntl.h>
 #include <signal.h>
@@ -269,6 +270,31 @@
 		}
 	}
 
+	/* close any open files to avoid hanging locks */
+	DIR *dp = opendir("/proc/self/fd");
+	if (dp != NULL) {
+		debugmsg("closing files based on /proc contents");
+		struct dirent *de;
+		while ((de = readdir(dp))) {
+			char *end;
+			long fd_value = strtol(de->d_name, &end, 10);
+			if (end == de->d_name) {
+				/* unable to convert to int (. or ..) */
+				continue;
+			}
+			if (errno == ERANGE) {
+				debugmsg("tried to parse %s, but range error occurred", de->d_name);
+				continue;
+			}
+			if (fd_value > STDERR_FILENO) {
+				int res = close(fd_value);
+				if (res) {
+					debugmsg("tried to close fd %ld: %d (errno: %d)", fd_value, res, errno);
+				}
+			}
+		}
+	}
+
 	if (putenv("CHGINTERNALMARK=") != 0)
 		abortmsgerrno("failed to putenv");
 	if (execvp(hgcmd, (char **)argv) < 0)
--- a/mercurial/crecord.py	Mon Oct 05 19:46:31 2020 -0700
+++ b/mercurial/crecord.py	Sat Nov 07 15:02:53 2020 -0500
@@ -1250,7 +1250,7 @@
                 self.numstatuslines,
                 0,
                 self.yscreensize - self.numstatuslines,
-                self.xscreensize,
+                self.xscreensize - 1,
             )
         except curses.error:
             pass