From bb4dd1f1733fe80493e3f165f206df675fb32beb Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Tue, 28 Jan 2014 14:10:53 +0100 Subject: src: Handle stale fds in dup() and dup2(). Reviewed-by: Stefan Metzmacher --- src/socket_wrapper.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src') diff --git a/src/socket_wrapper.c b/src/socket_wrapper.c index 0d74321..353a9a5 100644 --- a/src/socket_wrapper.c +++ b/src/socket_wrapper.c @@ -3934,6 +3934,9 @@ static int swrap_dup(int fd) return -1; } + /* Make sure we don't have an entry for the fd */ + swrap_remove_stale(fi->fd); + SWRAP_DLIST_ADD(si->fds, fi); return fi->fd; } @@ -3978,6 +3981,9 @@ static int swrap_dup2(int fd, int newfd) return -1; } + /* Make sure we don't have an entry for the fd */ + swrap_remove_stale(fi->fd); + SWRAP_DLIST_ADD(si->fds, fi); return fi->fd; } -- cgit