From 8e90e4c629df76a23b79e19814dbbcaef448ad07 Mon Sep 17 00:00:00 2001 From: jacob Date: Tue, 8 Mar 2005 23:06:15 +0000 Subject: [PATCH] Ben Hutchings reports that new PuTTY instances created from the saved sessions menu (etc) can inherit listening sockets, and that this sometimes causes trouble. Can't reproduce any problems myself, but let's only allow inheritance when absolutely necessary -- Duplicate Session -- in which case there's already going to be trouble with two processes trying to listen on the same port. git-svn-id: svn://svn.tartarus.org/sgt/putty@5468 cda61777-01e9-0310-a592-d414129be87e --- windows/window.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/windows/window.c b/windows/window.c index 40c69e54..066c4a45 100644 --- a/windows/window.c +++ b/windows/window.c @@ -1901,6 +1901,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, char b[2048]; char c[30], *cl; int freecl = FALSE; + BOOL inherit_handles; STARTUPINFO si; PROCESS_INFORMATION pi; HANDLE filemap = NULL; @@ -1929,6 +1930,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, UnmapViewOfFile(p); } } + inherit_handles = TRUE; sprintf(c, "putty &%p", filemap); cl = c; } else if (wParam == IDM_SAVEDSESS) { @@ -1938,11 +1940,14 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, char *session = sesslist.sessions[sessno]; /* XXX spaces? quotes? "-load"? */ cl = dupprintf("putty @%s", session); + inherit_handles = FALSE; freecl = TRUE; } else break; - } else + } else /* IDM_NEWSESS */ { cl = NULL; + inherit_handles = FALSE; + } GetModuleFileName(NULL, b, sizeof(b) - 1); si.cb = sizeof(si); @@ -1952,7 +1957,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, si.dwFlags = 0; si.cbReserved2 = 0; si.lpReserved2 = NULL; - CreateProcess(b, cl, NULL, NULL, TRUE, + CreateProcess(b, cl, NULL, NULL, inherit_handles, NORMAL_PRIORITY_CLASS, NULL, NULL, &si, &pi); if (filemap) -- 2.11.0