diff options
author | Peter Stephenson <p.w.stephenson@ntlworld.com> | 2015-10-24 20:24:35 +0100 |
---|---|---|
committer | Peter Stephenson <p.w.stephenson@ntlworld.com> | 2015-10-24 20:24:35 +0100 |
commit | 1f6dcf9bcdade41886e36826196e79502a9afa26 (patch) | |
tree | e9d95392ceb2b911f2973d5dbdee4d4dd9aa3706 /Src/Modules/tcp.c | |
parent | 8e9a68ad14655c1949b1a04d5715a5caa8c344ee (diff) | |
download | zsh-1f6dcf9bcdade41886e36826196e79502a9afa26.tar.gz zsh-1f6dcf9bcdade41886e36826196e79502a9afa26.tar.xz zsh-1f6dcf9bcdade41886e36826196e79502a9afa26.zip |
36941: Mark file descripors in ztcp as used.
Allow such file descriptors to be either internal and closed on exec or external and so managed explicitly by module.
Diffstat (limited to 'Src/Modules/tcp.c')
-rw-r--r-- | Src/Modules/tcp.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/Src/Modules/tcp.c b/Src/Modules/tcp.c index bc1765da1..274f01ffc 100644 --- a/Src/Modules/tcp.c +++ b/Src/Modules/tcp.c @@ -236,6 +236,8 @@ tcp_socket(int domain, int type, int protocol, int ztflags) if (!sess) return NULL; sess->fd = socket(domain, type, protocol); + /* We'll check failure and tidy up in caller */ + addmodulefd(sess->fd, FALSE); return sess; } @@ -298,7 +300,7 @@ tcp_close(Tcp_session sess) { if (sess->fd != -1) { - err = close(sess->fd); + err = zclose(sess->fd); if (err) zwarn("connection close failed: %e", errno); } @@ -546,6 +548,9 @@ bin_ztcp(char *nam, char **args, Options ops, UNUSED(int func)) return 1; } + /* redup expects fd is already registered */ + addmodulefd(rfd, FALSE); + if (targetfd) { sess->fd = redup(rfd, targetfd); if (sess->fd < 0) { |