summaryrefslogtreecommitdiffstats
path: root/Modules/socketmodule.c
diff options
context:
space:
mode:
Diffstat (limited to 'Modules/socketmodule.c')
-rw-r--r--Modules/socketmodule.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c
index c66d38c..c72c9fd 100644
--- a/Modules/socketmodule.c
+++ b/Modules/socketmodule.c
@@ -975,6 +975,10 @@ socket_fromfd(self, args)
if (!getargs(args, "(iiii)", &fd, &family, &type, &proto))
return NULL;
}
+ /* Dup the fd so it and the socket can be closed independently */
+ fd = dup(fd);
+ if (fd < 0)
+ return socket_error();
s = newsockobject(fd, family, type, proto);
/* From now on, ignore SIGPIPE and let the error checking
do the work. */