On 2014-11-01 15:53 +0000, ajs124 wrote:
> so I hit this bug which frequently prevents me from unmounting drives,
> because tmux has open file descriptors for directories on them.
> Those file descriptors are evidently not needed anymore, because I can
> attach gdb to the tmux process, close them manually and tmux works
> fine afterwards.

I've also hit this bug recently, it's quite annoying. After a quick scan
of the code, it seems that a directory is open for each client, session
and pane. I think the pane one might be the most annoying and it really
seems the code isn't using it for anything. I've attached a patch for
removing the per pane open cwd.

-- 
Balazs
>From 2a0ad4aa4ae913e8cab2f5078774e8cf3ec8e5af Mon Sep 17 00:00:00 2001
From: Balazs Kezes <rlblas...@gmail.com>
Date: Sat, 29 Nov 2014 20:05:00 +0000
Subject: [PATCH] Don't keep open the initial dir for each pane

It is not used anywhere anyways.
---
 tmux.h   | 1 -
 window.c | 8 +-------
 2 files changed, 1 insertion(+), 8 deletions(-)

diff --git a/tmux.h b/tmux.h
index 7c0a7b5..981bc3c 100644
--- a/tmux.h
+++ b/tmux.h
@@ -884,7 +884,6 @@ struct window_pane {
 	int		 argc;
 	char	       **argv;
 	char		*shell;
-	int		 cwd;
 
 	pid_t		 pid;
 	char		 tty[TTY_NAME_MAX];
diff --git a/window.c b/window.c
index 4d8cd1c..86259ef 100644
--- a/window.c
+++ b/window.c
@@ -681,7 +681,6 @@ window_pane_create(struct window *w, u_int sx, u_int sy, u_int hlimit)
 	wp->argc = 0;
 	wp->argv = NULL;
 	wp->shell = NULL;
-	wp->cwd = -1;
 
 	wp->fd = -1;
 	wp->event = NULL;
@@ -739,7 +738,6 @@ window_pane_destroy(struct window_pane *wp)
 
 	RB_REMOVE(window_pane_tree, &all_window_panes, wp);
 
-	close(wp->cwd);
 	free(wp->shell);
 	cmd_free_argv(wp->argc, wp->argv);
 	free(wp);
@@ -772,10 +770,6 @@ window_pane_spawn(struct window_pane *wp, int argc, char **argv,
 		free(wp->shell);
 		wp->shell = xstrdup(shell);
 	}
-	if (cwd != -1) {
-		close(wp->cwd);
-		wp->cwd = dup(cwd);
-	}
 
 	cmd = cmd_stringify_argv(wp->argc, wp->argv);
 	log_debug("spawn: %s -- %s", wp->shell, cmd);
@@ -793,7 +787,7 @@ window_pane_spawn(struct window_pane *wp, int argc, char **argv,
 		free(cmd);
 		return (-1);
 	case 0:
-		if (fchdir(wp->cwd) != 0)
+		if (fchdir(cwd) != 0)
 			chdir("/");
 
 		if (tcgetattr(STDIN_FILENO, &tio2) != 0)
-- 
2.1.3

------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk
_______________________________________________
tmux-users mailing list
tmux-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tmux-users

Reply via email to