1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-04-18 03:28:07 -05:00

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.

[originally from svn r5468]
This commit is contained in:
Jacob Nevins 2005-03-08 23:06:15 +00:00
parent 470bdd13ea
commit cb47941b61

View File

@ -1901,6 +1901,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
char b[2048]; char b[2048];
char c[30], *cl; char c[30], *cl;
int freecl = FALSE; int freecl = FALSE;
BOOL inherit_handles;
STARTUPINFO si; STARTUPINFO si;
PROCESS_INFORMATION pi; PROCESS_INFORMATION pi;
HANDLE filemap = NULL; HANDLE filemap = NULL;
@ -1929,6 +1930,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
UnmapViewOfFile(p); UnmapViewOfFile(p);
} }
} }
inherit_handles = TRUE;
sprintf(c, "putty &%p", filemap); sprintf(c, "putty &%p", filemap);
cl = c; cl = c;
} else if (wParam == IDM_SAVEDSESS) { } else if (wParam == IDM_SAVEDSESS) {
@ -1938,11 +1940,14 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
char *session = sesslist.sessions[sessno]; char *session = sesslist.sessions[sessno];
/* XXX spaces? quotes? "-load"? */ /* XXX spaces? quotes? "-load"? */
cl = dupprintf("putty @%s", session); cl = dupprintf("putty @%s", session);
inherit_handles = FALSE;
freecl = TRUE; freecl = TRUE;
} else } else
break; break;
} else } else /* IDM_NEWSESS */ {
cl = NULL; cl = NULL;
inherit_handles = FALSE;
}
GetModuleFileName(NULL, b, sizeof(b) - 1); GetModuleFileName(NULL, b, sizeof(b) - 1);
si.cb = sizeof(si); si.cb = sizeof(si);
@ -1952,7 +1957,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
si.dwFlags = 0; si.dwFlags = 0;
si.cbReserved2 = 0; si.cbReserved2 = 0;
si.lpReserved2 = NULL; si.lpReserved2 = NULL;
CreateProcess(b, cl, NULL, NULL, TRUE, CreateProcess(b, cl, NULL, NULL, inherit_handles,
NORMAL_PRIORITY_CLASS, NULL, NULL, &si, &pi); NORMAL_PRIORITY_CLASS, NULL, NULL, &si, &pi);
if (filemap) if (filemap)