summaryrefslogtreecommitdiffstats
path: root/innbbsd/closeonexec.c
diff options
context:
space:
mode:
authorin2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2002-03-07 23:13:44 +0800
committerin2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2002-03-07 23:13:44 +0800
commitae31e19f92e717919ac8e3db9039eb38d2b89aae (patch)
treec70164d6a1852344f44b04a653ae2815043512af /innbbsd/closeonexec.c
downloadpttbbs-ae31e19f92e717919ac8e3db9039eb38d2b89aae.tar
pttbbs-ae31e19f92e717919ac8e3db9039eb38d2b89aae.tar.gz
pttbbs-ae31e19f92e717919ac8e3db9039eb38d2b89aae.tar.bz2
pttbbs-ae31e19f92e717919ac8e3db9039eb38d2b89aae.tar.lz
pttbbs-ae31e19f92e717919ac8e3db9039eb38d2b89aae.tar.xz
pttbbs-ae31e19f92e717919ac8e3db9039eb38d2b89aae.tar.zst
pttbbs-ae31e19f92e717919ac8e3db9039eb38d2b89aae.zip
Initial revision
git-svn-id: http://opensvn.csie.org/pttbbs/pttbbs/trunk/pttbbs@1 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'innbbsd/closeonexec.c')
-rw-r--r--innbbsd/closeonexec.c66
1 files changed, 66 insertions, 0 deletions
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 <stdio.h>
+#include <sys/types.h>
+#include <errno.h>
+#include <sys/ioctl.h>
+#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 <termios.h>
+#else
+# include <sgtty.h>
+#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 <fcntl.h>
+
+
+/*
+** 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) */