diff options
author | Steve Bennett <steveb@workware.net.au> | 2011-05-27 12:00:33 +1000 |
---|---|---|
committer | Steve Bennett <steveb@workware.net.au> | 2011-05-27 12:00:33 +1000 |
commit | 2ce2fdbcc082424e9acd4604e76a90d378a003a0 (patch) | |
tree | a9f0a239ded6693ad9d9a3515b9929e1d8dc8373 | |
parent | 48f610a34db941af2c689b18c84ca7fd57e2c6d2 (diff) | |
download | jimtcl-2ce2fdbcc082424e9acd4604e76a90d378a003a0.zip jimtcl-2ce2fdbcc082424e9acd4604e76a90d378a003a0.tar.gz jimtcl-2ce2fdbcc082424e9acd4604e76a90d378a003a0.tar.bz2 |
Opened filehandles should be marked FD_CLOEXEC
This avoids them being inherited by child processes.
Signed-off-by: Steve Bennett <steveb@workware.net.au>
-rw-r--r-- | jim-aio.c | 4 |
1 files changed, 4 insertions, 0 deletions
@@ -597,9 +597,11 @@ static int aio_cmd_accept(Jim_Interp *interp, int argc, Jim_Obj *const *argv) /* Create the file command */ af = Jim_Alloc(sizeof(*af)); af->fd = sock; + fcntl(af->fd, F_SETFD, FD_CLOEXEC); af->filename = Jim_NewStringObj(interp, "accept", -1); Jim_IncrRefCount(af->filename); af->fp = fdopen(sock, "r+"); + af->OpenFlags = 0; #ifdef O_NDELAY af->flags = fcntl(af->fd, F_GETFL); @@ -957,6 +959,7 @@ static int JimAioOpenCommand(Jim_Interp *interp, int argc, af = Jim_Alloc(sizeof(*af)); af->fp = fp; af->fd = fileno(fp); + fcntl(af->fd, F_SETFD, FD_CLOEXEC); #ifdef O_NDELAY af->flags = fcntl(af->fd, F_GETFL); #endif @@ -1000,6 +1003,7 @@ static int JimMakeChannel(Jim_Interp *interp, Jim_Obj *filename, const char *hdl af = Jim_Alloc(sizeof(*af)); af->fp = fp; af->fd = fd; + fcntl(af->fd, F_SETFD, FD_CLOEXEC); af->OpenFlags = 0; af->filename = filename; Jim_IncrRefCount(af->filename); |