Class StandardOutputStream
- All Implemented Interfaces:
Closeable,Flushable,AutoCloseable
stdout with fd=1 as the stream to write to for the channel.
Using stdin/stdout pair for the communication is very convenient for setting up a remote channel,
so Jenkins tends to do that, but even with our using System.setOut(PrintStream) to avoid
other parts of the Java code to accidentally corrupt the stream, file descriptor 1 continues to
point to the stream we use, so native code in JVM can still accidentally pollute the stream.
Fixing that requires the use of dup and close POSIX API calls, which we can only do after the communication
gets established and JNA is brought in via remoting. Having Launcher uses this wrapper class allows
us to do that without recreating the stream.
When a channel uses StandardOutputStream to communicate, the convention is to make that object
available as a channel property.
- Author:
- Kohsuke Kawaguchi
-
Constructor Summary
Constructors -
Method Summary
Methods inherited from class java.io.OutputStream
nullOutputStream
-
Constructor Details
-
StandardOutputStream
public StandardOutputStream()
-
-
Method Details
-
swap
Atomically swaps the underlying stream to another stream and returns it. -
isSwapped
public boolean isSwapped() -
write
- Specified by:
writein classOutputStream- Throws:
IOException
-
write
- Overrides:
writein classOutputStream- Throws:
IOException
-
write
- Overrides:
writein classOutputStream- Throws:
IOException
-
flush
- Specified by:
flushin interfaceFlushable- Overrides:
flushin classOutputStream- Throws:
IOException
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classOutputStream- Throws:
IOException
-