We can simplify the code a bit if we make redup() return the target fd on success. The attached patch also adds a little more error checking for redup(). I'll check it in later on if nobody objects. ..wayne..