summaryrefslogtreecommitdiffstats
path: root/pttbbs/innbbsd/closeonexec.c
blob: b41fdd6987ff5ff256c808f95a8465243f85935a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/*
 * $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_FCNTL
#define CLX_FCNTL
#endif





#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 ? FD_CLOEXEC : 0);
    errno = oerrno;
}
#endif              /* defined(CLX_FCNTL) */