Re: [JSch-users] Backgrounding stops in JSCH
Status: Alpha
Brought to you by:
ymnk
From: <ym...@jc...> - 2003-01-15 17:58:58
|
Hi, +-From: "Bernstein, Brian J" <Bri...@le...> __ |_Date: Wed, 15 Jan 2003 11:05:41 -0500 ____________________ | >> Hello, I'm trying to track down a problem that I am fairly >> certain exists due to JSCH. >> >> However, if I run the launching process backgrounded (even >> nohup'd), at some point in JSCH's work it causes the background >> process to stop. Not a freeze in the code, but "[1]+ Stopped - >> launcherProcess" type stop which from my experience happens >> when a background program tries to grab STDIN. If I let the >> program run in foreground, it works perfectly. No, I do not >> touch STDIN anywhere, and my output is either via Tibco or >> log4j. You are right. STDIN will be grabbed, because System.{in,out} are plugged to a remote process by the default. So, the followings will solve your problem >> com.jcraft.jsch.Channel channel = session.openChannel("exec"); >> ((ChannelExec) channel).setCommand(cmd); >> channel.setXForwarding(false); PipedOutputStream out=new PipedOutputStream(); channel.setInputStream(new PipedInputStream(out)); PipedInputStream in=new PipedInputStream(); channel.setOutputStream(new PipedOutputStream(in)); >> channel.connect(); >> >> successFlag = true; From my carelessness, you can not write as follows in current release, channel.setInputStream(null); channel.setOutputStream(null); but you will be able to do in the next release. Thanks, -- ymnk |