dup2 on Sys5r2 ish box

Brandon S. Allbery KB8JRR/AA allbery at NCoast.ORG
Sun Apr 14 04:33:14 AEST 1991


As quoted from <2180 at estevax.UUCP> by iain at estevax.UUCP (Hr Iain Lea):
+---------------
| I am porting a program from BSD to a Sys5r2 ish derivative and need the
| dup2() function call.
+---------------

Is this one in the FAQ?

/*
 * Near-duplicate for dup2().  ("Near"?  We discussed this for a whole bloody
 * month --- I don't want to discuss it any more.  BSD and System V have
 * enough differing errno values that that part is pointless anyway.)
 *
 * Caveats: doesn't necessarily return the same errno values on failure; does
 * not leave f2 open if the dup fails.
 */

#include <ioctl.h>
#include <errno.h>

#define dup2(f1,f2) (close(f2),fcntl(f1,F_DUPFD,f2))

++Brandon

-- 
Me: Brandon S. Allbery			  Ham: KB8JRR/AA on 2m, 220, 440, 1200
Internet: allbery at NCoast.ORG		(QRT on HF until local problems fixed)
America OnLine: KB8JRR // Delphi: ALLBERY   AMPR: kb8jrr.AmPR.ORG [44.70.4.88]
uunet!usenet.ins.cwru.edu!ncoast!allbery          KB8JRR @ WA8BXN.OH



More information about the Comp.unix.wizards mailing list