1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-07-05 21:42:47 -05:00

I've just discovered that using the saved sessions menu from Unix

PuTTY causes the child process to inherit a lot of socket fds from
its parent, which is a pain if one of them then ends up holding open
a listening socket which the parent was using for port forwarding
after the parent itself is dead.

Therefore, this checkin sprinkles FD_CLOEXEC throughout the Unix
platform directory wherever there looks like being a long-lived fd.

[originally from svn r6917]
This commit is contained in:
Simon Tatham
2006-11-23 14:32:11 +00:00
parent 230d400ddc
commit fd6d9bd677
4 changed files with 16 additions and 1 deletions

View File

@ -8,6 +8,7 @@
#include <unistd.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <fcntl.h>
#include "putty.h"
#include "misc.h"
@ -121,6 +122,8 @@ int agent_query(void *in, int inlen, void **out, int *outlen,
exit(1);
}
fcntl(sock, F_SETFD, FD_CLOEXEC);
addr.sun_family = AF_UNIX;
strncpy(addr.sun_path, name, sizeof(addr.sun_path));
if (connect(sock, (struct sockaddr *)&addr, sizeof(addr)) < 0) {