1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-03 23:25:26 +02:00

[175308] Need to use a job to wait for shell to exit

This commit is contained in:
David McKnight 2007-07-24 16:11:22 +00:00
parent eaa29d65f7
commit bc4c33cc44
3 changed files with 57 additions and 45 deletions

View file

@ -24,11 +24,7 @@ import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.rse.core.model.IHost;
import org.eclipse.rse.services.clientserver.processes.ISystemProcessRemoteConstants;
@ -141,35 +137,6 @@ public class LinuxProcessHelper {
waiter.schedule();
}
/*
* Job that waits until a remote process has exited
*/
class WaiterJob extends Job
{
private Process _p;
public WaiterJob(Process p)
{
super("LinuxShellProcessWaiter"); //$NON-NLS-1$
_p = p;
}
public IStatus run(IProgressMonitor monitor) {
try {
_p.waitFor();
if (_p.exitValue()!=0)
{
String errMsg = Activator.getErrorMessage(_p.getErrorStream());
if (!errMsg.trim().equals("")) { //$NON-NLS-1$
Activator.logErrorMessage(errMsg.toString());
}
}
} catch(InterruptedException e) {
return Status.CANCEL_STATUS;
}
return Status.OK_STATUS;
}
}
/**
* Gets the uid associated with the given username on this system
*/

View file

@ -9,6 +9,7 @@
* Yu-Fen Kuo (MontaVista) - initial API and implementation
* Martin Oberhuber (Wind River) - [refactor] "shell" instead of "ssh" everywhere
* Martin Oberhuber (Wind River) - [186128] Move IProgressMonitor last in all API
* David McKnight (IBM) - [175308] Need to use a job to wait for shell to exit
*******************************************************************************/
package org.eclipse.rse.internal.subsystems.processes.shell.linux;
@ -166,12 +167,11 @@ public class LinuxShellProcessService extends AbstractProcessService {
} catch (IOException e) {
Activator.log(e);
}
if (p.exitValue() != 0) {
String errMsg = Activator.getErrorMessage(p.getErrorStream());
if (!errMsg.trim().equals("")) { //$NON-NLS-1$
Activator.logErrorMessage(errMsg.toString());
}
}
// Wait for remote process to exit.
WaiterJob waiter = new WaiterJob(p);
waiter.schedule();
return (IHostProcess[]) hostProcessList
.toArray(new IHostProcess[hostProcessList.size()]);
}
@ -253,12 +253,11 @@ public class LinuxShellProcessService extends AbstractProcessService {
} catch (IOException e) {
Activator.log(e);
}
if (p.exitValue() != 0) {
String errMsg = Activator.getErrorMessage(p.getErrorStream());
if (!errMsg.toString().trim().equals("")) { //$NON-NLS-1$
Activator.logErrorMessage(errMsg.toString());
}
}
// Wait for remote process to exit.
WaiterJob waiter = new WaiterJob(p);
waiter.schedule();
if (lines == null || lines.size() <= 0) {
Activator.logErrorMessage(LinuxShellProcessResources.LinuxRemoteProcessService_getSignalTypes_empty);
} else {

View file

@ -0,0 +1,46 @@
/********************************************************************************
* Copyright (c) 2007 IBM Corporation. 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
*
* Initial Contributors:
* The following IBM employees contributed to the Remote System Explorer
* component that contains this file: David McKnight.
*
* Contributors:
* David McKnight (IBM) - [175308] Need to use a job to wait for shell to exit
********************************************************************************/
package org.eclipse.rse.internal.subsystems.processes.shell.linux;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
class WaiterJob extends Job
{
private Process _p;
public WaiterJob(Process p)
{
super("LinuxShellProcessWaiter"); //$NON-NLS-1$
_p = p;
setSystem(true);
}
public IStatus run(IProgressMonitor monitor) {
try {
_p.waitFor();
if (_p.exitValue()!=0)
{
String errMsg = Activator.getErrorMessage(_p.getErrorStream());
if (!errMsg.trim().equals("")) { //$NON-NLS-1$
Activator.logErrorMessage(errMsg.toString());
}
}
} catch(InterruptedException e) {
return Status.CANCEL_STATUS;
}
return Status.OK_STATUS;
}
}