[comp.unix.wizards] dup2 on Sys5r2 ish box

iain@estevax.UUCP (Hr Iain Lea) (04/09/91)

I am porting a program from BSD to a Sys5r2 ish derivative and need the
dup2() function call.

Does it exist under vanilla Sys5r2 and if so is it freely available or
do I need a AT&T licence?

Or has anyone got a piece of code they can mail me ?

Thanx

Iain

allbery@NCoast.ORG (Brandon S. Allbery KB8JRR/AA) (04/14/91)

As quoted from <2180@estevax.UUCP> by iain@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@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