summaryrefslogtreecommitdiffhomepage
path: root/common-channel.c
diff options
context:
space:
mode:
Diffstat (limited to 'common-channel.c')
-rw-r--r--common-channel.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/common-channel.c b/common-channel.c
index f03039a..dfff1b4 100644
--- a/common-channel.c
+++ b/common-channel.c
@@ -1019,6 +1019,7 @@ static void closechanfd(struct Channel *channel, int fd, int how) {
/* XXX server */
if (channel->type->sepfds) {
+ TRACE(("shutdown((%d), %d)", fd, how))
shutdown(fd, how);
if (how == 0) {
closeout = 1;
@@ -1043,4 +1044,11 @@ static void closechanfd(struct Channel *channel, int fd, int how) {
if (closein && (channel->extrabuf != NULL) && (fd == channel->errfd)) {
channel->errfd = FD_CLOSED;
}
+
+ /* if we called shutdown on it and all references are gone, then we
+ * need to close() it to stop it lingering */
+ if (channel->type->sepfds && channel->outfd == FD_CLOSED
+ && channel->infd == FD_CLOSED && channel->errfd == FD_CLOSED) {
+ close(fd);
+ }
}