mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-24 09:25:31 +02:00
Bug 286162 - Debug core logs spawner IO exception when running C/C++ executable on Linux
This commit is contained in:
parent
581d1af49f
commit
7d24065c7d
2 changed files with 44 additions and 19 deletions
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2000, 2008 QNX Software Systems and others.
|
||||
* Copyright (c) 2000, 2010 QNX Software Systems and others.
|
||||
* 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
|
||||
|
@ -7,6 +7,7 @@
|
|||
*
|
||||
* Contributors:
|
||||
* QNX Software Systems - Initial API and implementation
|
||||
* Wind River Systems - bug 286162
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.utils.pty;
|
||||
|
||||
|
@ -14,7 +15,6 @@ package org.eclipse.cdt.utils.pty;
|
|||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.utils.pty.PTY.MasterFD;
|
||||
|
||||
class PTYInputStream extends InputStream {
|
||||
|
@ -74,9 +74,10 @@ class PTYInputStream extends InputStream {
|
|||
public void close() throws IOException {
|
||||
if (master.getFD() == -1)
|
||||
return;
|
||||
int status = close0(master.getFD());
|
||||
if (status == -1)
|
||||
throw new IOException(CCorePlugin.getResourceString("Util.exception.closeError")); //$NON-NLS-1$
|
||||
close0(master.getFD());
|
||||
// ignore error on close - see bug 286162
|
||||
// if (status == -1)
|
||||
// throw new IOException(CCorePlugin.getResourceString("Util.exception.closeError")); //$NON-NLS-1$
|
||||
master.setFD(-1);
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
*
|
||||
* Contributors:
|
||||
* QNX Software Systems - Initial API and implementation
|
||||
* Wind River Systems, Inc. - bug 248071
|
||||
* Wind River Systems - bug 248071, bug 286162
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.utils.spawner;
|
||||
|
||||
|
@ -66,6 +66,7 @@ public class Spawner extends Process {
|
|||
OutputStream out;
|
||||
InputStream in;
|
||||
InputStream err;
|
||||
private PTY fPty;
|
||||
|
||||
public Spawner(String command, boolean bNoRedirect) throws IOException {
|
||||
StringTokenizer tokenizer = new StringTokenizer(command);
|
||||
|
@ -92,6 +93,7 @@ public class Spawner extends Process {
|
|||
String dirpath = "."; //$NON-NLS-1$
|
||||
if (dir != null)
|
||||
dirpath = dir.getAbsolutePath();
|
||||
fPty = pty;
|
||||
exec_pty(cmdarray, envp, dirpath, pty);
|
||||
}
|
||||
/**
|
||||
|
@ -144,8 +146,13 @@ public class Spawner extends Process {
|
|||
**/
|
||||
@Override
|
||||
public InputStream getInputStream() {
|
||||
if(null == in)
|
||||
in = new SpawnerInputStream(fChannels[1]);
|
||||
if(null == in) {
|
||||
if (fPty != null) {
|
||||
in = fPty.getInputStream();
|
||||
} else {
|
||||
in = new SpawnerInputStream(fChannels[1]);
|
||||
}
|
||||
}
|
||||
return in;
|
||||
}
|
||||
|
||||
|
@ -154,8 +161,13 @@ public class Spawner extends Process {
|
|||
**/
|
||||
@Override
|
||||
public OutputStream getOutputStream() {
|
||||
if(null == out)
|
||||
out = new SpawnerOutputStream(fChannels[0]);
|
||||
if(null == out) {
|
||||
if (fPty != null) {
|
||||
out = fPty.getOutputStream();
|
||||
} else {
|
||||
out = new SpawnerOutputStream(fChannels[0]);
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
|
@ -164,8 +176,21 @@ public class Spawner extends Process {
|
|||
**/
|
||||
@Override
|
||||
public InputStream getErrorStream() {
|
||||
if(null == err)
|
||||
err = new SpawnerInputStream(fChannels[2]);
|
||||
if(null == err) {
|
||||
if (fPty != null && !fPty.isConsole()) {
|
||||
// If PTY is used and it's not in "Console" mode, then stderr is
|
||||
// redirected to the PTY's output stream. Therefore, return a
|
||||
// dummy stream for error stream.
|
||||
err = new InputStream() {
|
||||
@Override
|
||||
public int read() throws IOException {
|
||||
return -1;
|
||||
}
|
||||
};
|
||||
} else {
|
||||
err = new SpawnerInputStream(fChannels[2]);
|
||||
}
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
|
@ -179,12 +204,11 @@ public class Spawner extends Process {
|
|||
}
|
||||
try {
|
||||
if(null == err)
|
||||
((SpawnerInputStream)getErrorStream()).close();
|
||||
getErrorStream().close();
|
||||
if(null == in)
|
||||
((SpawnerInputStream)getInputStream()).close();
|
||||
getInputStream().close();
|
||||
if(null == out)
|
||||
((SpawnerOutputStream)getOutputStream()).close();
|
||||
|
||||
getOutputStream().close();
|
||||
} catch (IOException e) {
|
||||
}
|
||||
return status;
|
||||
|
@ -211,11 +235,11 @@ public class Spawner extends Process {
|
|||
// Close the streams on this side.
|
||||
try {
|
||||
if(null == err)
|
||||
((SpawnerInputStream)getErrorStream()).close();
|
||||
getErrorStream().close();
|
||||
if(null == in)
|
||||
((SpawnerInputStream)getInputStream()).close();
|
||||
getInputStream().close();
|
||||
if(null == out)
|
||||
((SpawnerOutputStream)getOutputStream()).close();
|
||||
getOutputStream().close();
|
||||
} catch (IOException e) {
|
||||
}
|
||||
// Grace before using the heavy gone.
|
||||
|
|
Loading…
Add table
Reference in a new issue