Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 52461 Details for
Bug 161838
Local shell reports isActive wrong
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
The modified HostShellAdapter.java from RSE 1.0RC2 that prints the isActive status.
HostShellAdapter.java (text/plain), 3.61 KB, created by
Lothar Werzinger
on 2006-10-21 11:38:54 EDT
(
hide
)
Description:
The modified HostShellAdapter.java from RSE 1.0RC2 that prints the isActive status.
Filename:
MIME Type:
Creator:
Lothar Werzinger
Created:
2006-10-21 11:38:54 EDT
Size:
3.61 KB
patch
obsolete
>/******************************************************************************* > * Copyright (c) 2006 PalmSource, Inc. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at > * http://www.eclipse.org/legal/epl-v10.html > * > * Contributors: > * Ewa Matejska (PalmSource) > *******************************************************************************/ > >package biz.tradescape.debug.launching; > >import java.io.IOException; >import java.io.InputStream; >import java.io.OutputStream; >import java.io.PipedInputStream; >import java.io.PipedOutputStream; > >import org.eclipse.rse.services.shells.IHostShell; >import org.eclipse.rse.services.shells.IHostShellChangeEvent; >import org.eclipse.rse.services.shells.IHostShellOutputListener; > >public class HostShellAdapter extends Process implements >IHostShellOutputListener { > > private IHostShell hostShell; > private PipedInputStream inputStream = null; > private PipedInputStream errorStream = null; > private HostShellOutputStream outputStream = null; > > private PipedOutputStream hostShellInput = null; > private PipedOutputStream hostShellError = null; > > > public HostShellAdapter(IHostShell hostShell) throws java.io.IOException { > this.hostShell = hostShell; > hostShellInput = new PipedOutputStream(); > hostShellError = new PipedOutputStream(); > inputStream = new PipedInputStream(hostShellInput); > errorStream = new PipedInputStream(hostShellError); > outputStream = new HostShellOutputStream(hostShell); > this.hostShell.getStandardOutputReader().addOutputListener(this); > this.hostShell.getStandardErrorReader().addOutputListener(this); > } > > public synchronized void destroy() { > System.out.println("destroy() - before hostShell.exit();"); > hostShell.exit(); > System.out.println("destroy() - after hostShell.exit();"); > notifyAll(); > try { > hostShellInput.close(); > hostShellError.close(); > inputStream.close(); > errorStream.close(); > outputStream.close(); > } catch (IOException e) { > // Ignore > } > } > > public synchronized int exitValue() { > System.out.println("exitValue() - hostShell.isActive()=" + hostShell.isActive()); > if(hostShell.isActive()) > throw new IllegalThreadStateException(); > // No way to tell what the exit value was. > return 0; > } > > public InputStream getErrorStream() { > return errorStream; > } > > public InputStream getInputStream() { > return inputStream; > } > > public OutputStream getOutputStream() { > return outputStream; > } > > public synchronized int waitFor() throws InterruptedException { > > while(hostShell.isActive()) { > try { > wait(1000); > } catch (InterruptedException e) { > // ignore because we're polling to see if shell is still active. > } > } > > try { > // Wait a second to try to get some more output from the target shell before closing. > wait(1000); > // Allow for the data from the stream to be read if it's available > if (inputStream.available() != 0 || errorStream.available() != 0) > throw new InterruptedException(); > > hostShellInput.close(); > hostShellError.close(); > inputStream.close(); > errorStream.close(); > outputStream.close(); > } catch (IOException e) { > // Ignore > } > return 0; > } > > public void shellOutputChanged(IHostShellChangeEvent event) { > Object[] input = event.getLines(); > OutputStream outputStream = event.isError() ? hostShellError : hostShellInput; > try { > for(int i = 0; i < input.length; i++) { > outputStream.write(input[i].toString().getBytes()); > outputStream.write('\n'); > outputStream.flush(); > } > } catch(IOException e) { > // Ignore > } > } > >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Flags:
mober.at+eclipse
:
iplog+
Actions:
View
Attachments on
bug 161838
: 52461 |
52645