On Wed, Jul 15, 2015 at 05:45:49PM +0200, v4hn wrote:
> On Wed, Jul 15, 2015 at 11:32:38AM -0400, Ross Mohn wrote:
> > $ pstree -p 2199
> > dvtm(2199)─┬─sh(2239)───bash(2240)───mutt(11096)
> > ├─sh(2324)───bash(2325)
> > ├─sh(12015)───bash(12016)───vim(17544)
> > └─sh(12116)───bash(12117)───pstree(21626)
>
> Fix your setup. Spawning two shells is stupid already,
> but to keep the outer shell (your "generic sh") running
> is insane.
>
> exec could help, but reviewing the spawn process to avoid sh
> to spawn "your" shell would be better.
Thanks, that led me to the solution! Patch is attached, and should work
for all users. Please test and apply.
-Ross
diff --git a/dvtm.c b/dvtm.c
index cd8178d..dbacb39 100644
--- a/dvtm.c
+++ b/dvtm.c
@@ -987,7 +987,7 @@ static char *getcwd_by_pid(Client *c) {
static void
create(const char *args[]) {
const char *cmd = (args && args[0]) ? args[0] : shell;
- const char *pargs[] = { "/bin/sh", "-c", cmd, NULL };
+ const char *pargs[] = { shell, "-c", cmd, NULL };
char buf[8], *cwd = NULL;
const char *env[] = {
"DVTM_WINDOW_ID", buf,
@@ -1020,7 +1020,7 @@ create(const char *args[]) {
}
if (args && args[2])
cwd = !strcmp(args[2], "$CWD") ? getcwd_by_pid(sel) : (char*)args[2];
- c->pid = vt_forkpty(c->term, "/bin/sh", pargs, cwd, env, NULL, NULL);
+ c->pid = vt_forkpty(c->term, shell, pargs, cwd, env, NULL, NULL);
if (args && args[2] && !strcmp(args[2], "$CWD"))
free(cwd);
vt_data_set(c->term, c);