Skip to content

Commit

Permalink
signalCloseToRemote property which allows to optionally send CHANNEL_…
Browse files Browse the repository at this point in the history
…EOF on close()
  • Loading branch information
jpstotz committed Jan 23, 2020
1 parent d10a33e commit 40a7ef0
Showing 1 changed file with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public final class ChannelOutputStream extends OutputStream implements ErrorNoti
private final byte[] b = new byte[1];

private boolean closed;
private boolean signalCloseToRemote = false;
private SSHException error;

private final class DataBuffer {
Expand Down Expand Up @@ -163,7 +164,9 @@ public synchronized void close() throws IOException {
if (!closed) {
try {
buffer.flush(false);
// trans.write(new SSHPacket(Message.CHANNEL_EOF).putUInt32(chan.getRecipient()));
if (signalCloseToRemote) {
trans.write(new SSHPacket(Message.CHANNEL_EOF).putUInt32(chan.getRecipient()));
}
} finally {
closed = true;
}
Expand All @@ -187,4 +190,20 @@ public String toString() {
return "< ChannelOutputStream for Channel #" + chan.getID() + " >";
}

public boolean isSignalCloseToRemote() {
return signalCloseToRemote;
}

/**
* @param signalCloseToRemote <code>true</code>: when calling {@link #close()} the remote side will be informed
* that no further input will be received. Effectively this means that the remote
* command will get an EOF on stdin. This is only important for remote commands that
* process data from stdin (e.g. files) and do not terminate until they get an EOF for
* stdin.
* <p>
* By default the remote side will not be informed that the stream has been closed.
*/
public void setSignalCloseToRemote(boolean signalCloseToRemote) {
this.signalCloseToRemote = signalCloseToRemote;
}
}

0 comments on commit 40a7ef0

Please sign in to comment.