diff options
author | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2008-03-20 19:33:49 +0800 |
---|---|---|
committer | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2008-03-20 19:33:49 +0800 |
commit | 6c7b18b32d87c2a835f7e5c48faac4a8ad44668b (patch) | |
tree | e88e1b2b1007f4ddcd348a4a1bf1d13c515c4564 /daemon/innbbsd/closeonexec.c | |
parent | f59699c22c130373cda3cc4cb6fab5bae510bd5a (diff) | |
download | pttbbs-6c7b18b32d87c2a835f7e5c48faac4a8ad44668b.tar pttbbs-6c7b18b32d87c2a835f7e5c48faac4a8ad44668b.tar.gz pttbbs-6c7b18b32d87c2a835f7e5c48faac4a8ad44668b.tar.bz2 pttbbs-6c7b18b32d87c2a835f7e5c48faac4a8ad44668b.tar.lz pttbbs-6c7b18b32d87c2a835f7e5c48faac4a8ad44668b.tar.xz pttbbs-6c7b18b32d87c2a835f7e5c48faac4a8ad44668b.tar.zst pttbbs-6c7b18b32d87c2a835f7e5c48faac4a8ad44668b.zip |
- (internal/exp) first draft of new layoutpiaip.newlayout
git-svn-id: http://opensvn.csie.org/pttbbs/branches/piaip.newlayout@4013 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'daemon/innbbsd/closeonexec.c')
-rw-r--r-- | daemon/innbbsd/closeonexec.c | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/daemon/innbbsd/closeonexec.c b/daemon/innbbsd/closeonexec.c new file mode 100644 index 00000000..1fd1a24e --- /dev/null +++ b/daemon/innbbsd/closeonexec.c @@ -0,0 +1,69 @@ +/* + * $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) */ |