From: Sean Hefty Date: Fri, 7 Sep 2012 17:20:53 +0000 (-0700) Subject: rspreload: Fix state checks in dup2 X-Git-Tag: v1.0.17~27 X-Git-Url: https://openfabrics.org/gitweb/?a=commitdiff_plain;h=3524c878f537ef2c57f973fad54b1204c299026d;p=~shefty%2Flibrdmacm.git rspreload: Fix state checks in dup2 The patch to add dup2 support was never updated to handle the fd state. The check for the fd type == fd_fork is no longer valid. We need to instead check the fd state before handling forking. Problem pointed out by Alex Couvrard Signed-off-by: Sean Hefty --- diff --git a/src/preload.c b/src/preload.c index 4ba38f5f..fb2149bf 100644 --- a/src/preload.c +++ b/src/preload.c @@ -978,8 +978,12 @@ int dup2(int oldfd, int newfd) init_preload(); oldfdi = idm_lookup(&idm, oldfd); - if (oldfdi && oldfdi->type == fd_fork) - fork_passive(oldfd); + if (oldfdi) { + if (oldfdi->state == fd_fork_passive) + fork_passive(oldfd); + else if (oldfdi->state == fd_fork_active) + fork_active(oldfd); + } newfdi = idm_lookup(&idm, newfd); if (newfdi) {