From ae31e19f92e717919ac8e3db9039eb38d2b89aae Mon Sep 17 00:00:00 2001 From: in2 Date: Thu, 7 Mar 2002 15:13:44 +0000 Subject: Initial revision git-svn-id: http://opensvn.csie.org/pttbbs/pttbbs/trunk/pttbbs@1 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- innbbsd/closeonexec.c | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 innbbsd/closeonexec.c (limited to 'innbbsd/closeonexec.c') diff --git a/innbbsd/closeonexec.c b/innbbsd/closeonexec.c new file mode 100644 index 00000000..e005e51b --- /dev/null +++ b/innbbsd/closeonexec.c @@ -0,0 +1,66 @@ +/* $Revision: 1.1 $ +** +*/ +/*#include "configdata.h"*/ +#include +#include +#include +#include +#include "clibrary.h" + +#ifndef CLX_IOCTL +# define CLX_IOCTL +#endif +#ifndef CLX_FCNTL +# define CLX_FCNTL +#endif + + + +#if defined(CLX_IOCTL) && !defined(IRIX) +#ifdef __linux +# include +#else +# include +#endif + + +/* +** Mark a file close-on-exec so that it doesn't get shared with our +** children. Ignore any error codes. +*/ +void +closeOnExec(fd, flag) + int fd; + int flag; +{ + int oerrno; + + oerrno = errno; + (void)ioctl(fd, flag ? FIOCLEX : FIONCLEX, (char *)NULL); + errno = oerrno; +} +#endif /* defined(CLX_IOCTL) */ + + + +#if defined(CLX_FCNTL) +#include + + +/* +** Mark a file close-on-exec so that it doesn't get shared with our +** children. Ignore any error codes. +*/ +void +CloseOnExec(fd, flag) + int fd; + int flag; +{ + int oerrno; + + oerrno = errno; + (void)fcntl(fd, F_SETFD, flag ? 1 : 0); + errno = oerrno; +} +#endif /* defined(CLX_FCNTL) */ -- cgit v1.2.3