Skip to content

Commit

Permalink
Final changes for STREAMClose
Browse files Browse the repository at this point in the history
  • Loading branch information
ColumPaget committed Jan 31, 2020
1 parent d5a8841 commit a5d6338
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -1113,7 +1113,7 @@ void STREAMCloseFile(STREAM *S)
{
if (
(StrEnd(S->Path)) ||
(strcmp(S->Path,"-") !=0)
(strcmp(S->Path,"-") !=0) //don't do this for stdin/stdout
)
{
if (S->out_fd != -1)
Expand Down Expand Up @@ -1185,6 +1185,8 @@ void STREAMClose(STREAM *S)
Curr=ListGetNext(Curr);
}

//associate streams are streams that support other streams, like the ssh connection that
//supports a port-forward through ssh. We close these down when the owner stream is closed
Curr=ListGetNext(S->Items);
while (Curr)
{
Expand All @@ -1198,6 +1200,7 @@ void STREAMClose(STREAM *S)
Curr=ListGetNext(Curr);
}

//now we actually close the file descriptors for this stream
if ((S->out_fd != S->in_fd) && (S->out_fd > -1)) close(S->out_fd);
if (S->in_fd > -1) close(S->in_fd);

Expand Down

0 comments on commit a5d6338

Please sign in to comment.