-
Notifications
You must be signed in to change notification settings - Fork 187
Open
Description
Hello,
Consider this code:
JSch jsch = new JSch();
Session session = jsch.getSession(USER, HOST, 22);
session.setPassword(PASSWORD);
session.setConfig("StrictHostKeyChecking", "no");
session.connect();
ChannelExec channel = (ChannelExec) session.openChannel("exec");
channel.setCommand(COMMAND);
channel.setErrStream(System.err);
channel.setInputStream(null);
channel.setOutputStream(System.out);
channel.connect();
while (!channel.isClosed()) {
sleep(100, TimeUnit.MILLISECONDS);
}
channel.disconnect();
session.disconnect();After that code runs, when I try to do System.out.println() it doesn't work. It's like the library is not releasing System.out.
I did a little digging into the classes and found this in the IO class:
/*
public void finalize() throws Throwable{
try{
if(in!=null) in.close();
}
catch(Exception ee){}
try{
if(out!=null) out.close();
}
catch(Exception ee){}
try{
if(out_ext!=null) out_ext.close();
}
catch(Exception ee){}
}
*/And was wondering if that code being commented out has anything to do with it?
I found a work around by creating a custom OutputStream object then redirecting the channel to that and then in there I have it print to System.out. Doing it that way I don't ever lose the ability to print to console.
Do you have any idea why this is happening?
Metadata
Metadata
Assignees
Labels
No labels