mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-09-09 11:33:20 +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
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -7,6 +7,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* QNX Software Systems - Initial API and implementation
|
* QNX Software Systems - Initial API and implementation
|
||||||
|
* Wind River Systems - bug 286162
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.utils.pty;
|
package org.eclipse.cdt.utils.pty;
|
||||||
|
|
||||||
|
@ -14,7 +15,6 @@ package org.eclipse.cdt.utils.pty;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
|
||||||
import org.eclipse.cdt.utils.pty.PTY.MasterFD;
|
import org.eclipse.cdt.utils.pty.PTY.MasterFD;
|
||||||
|
|
||||||
class PTYInputStream extends InputStream {
|
class PTYInputStream extends InputStream {
|
||||||
|
@ -74,9 +74,10 @@ class PTYInputStream extends InputStream {
|
||||||
public void close() throws IOException {
|
public void close() throws IOException {
|
||||||
if (master.getFD() == -1)
|
if (master.getFD() == -1)
|
||||||
return;
|
return;
|
||||||
int status = close0(master.getFD());
|
close0(master.getFD());
|
||||||
if (status == -1)
|
// ignore error on close - see bug 286162
|
||||||
throw new IOException(CCorePlugin.getResourceString("Util.exception.closeError")); //$NON-NLS-1$
|
// if (status == -1)
|
||||||
|
// throw new IOException(CCorePlugin.getResourceString("Util.exception.closeError")); //$NON-NLS-1$
|
||||||
master.setFD(-1);
|
master.setFD(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* QNX Software Systems - Initial API and implementation
|
* 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;
|
package org.eclipse.cdt.utils.spawner;
|
||||||
|
|
||||||
|
@ -66,6 +66,7 @@ public class Spawner extends Process {
|
||||||
OutputStream out;
|
OutputStream out;
|
||||||
InputStream in;
|
InputStream in;
|
||||||
InputStream err;
|
InputStream err;
|
||||||
|
private PTY fPty;
|
||||||
|
|
||||||
public Spawner(String command, boolean bNoRedirect) throws IOException {
|
public Spawner(String command, boolean bNoRedirect) throws IOException {
|
||||||
StringTokenizer tokenizer = new StringTokenizer(command);
|
StringTokenizer tokenizer = new StringTokenizer(command);
|
||||||
|
@ -92,6 +93,7 @@ public class Spawner extends Process {
|
||||||
String dirpath = "."; //$NON-NLS-1$
|
String dirpath = "."; //$NON-NLS-1$
|
||||||
if (dir != null)
|
if (dir != null)
|
||||||
dirpath = dir.getAbsolutePath();
|
dirpath = dir.getAbsolutePath();
|
||||||
|
fPty = pty;
|
||||||
exec_pty(cmdarray, envp, dirpath, pty);
|
exec_pty(cmdarray, envp, dirpath, pty);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -144,8 +146,13 @@ public class Spawner extends Process {
|
||||||
**/
|
**/
|
||||||
@Override
|
@Override
|
||||||
public InputStream getInputStream() {
|
public InputStream getInputStream() {
|
||||||
if(null == in)
|
if(null == in) {
|
||||||
in = new SpawnerInputStream(fChannels[1]);
|
if (fPty != null) {
|
||||||
|
in = fPty.getInputStream();
|
||||||
|
} else {
|
||||||
|
in = new SpawnerInputStream(fChannels[1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
return in;
|
return in;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,8 +161,13 @@ public class Spawner extends Process {
|
||||||
**/
|
**/
|
||||||
@Override
|
@Override
|
||||||
public OutputStream getOutputStream() {
|
public OutputStream getOutputStream() {
|
||||||
if(null == out)
|
if(null == out) {
|
||||||
out = new SpawnerOutputStream(fChannels[0]);
|
if (fPty != null) {
|
||||||
|
out = fPty.getOutputStream();
|
||||||
|
} else {
|
||||||
|
out = new SpawnerOutputStream(fChannels[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -164,8 +176,21 @@ public class Spawner extends Process {
|
||||||
**/
|
**/
|
||||||
@Override
|
@Override
|
||||||
public InputStream getErrorStream() {
|
public InputStream getErrorStream() {
|
||||||
if(null == err)
|
if(null == err) {
|
||||||
err = new SpawnerInputStream(fChannels[2]);
|
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;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -179,12 +204,11 @@ public class Spawner extends Process {
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
if(null == err)
|
if(null == err)
|
||||||
((SpawnerInputStream)getErrorStream()).close();
|
getErrorStream().close();
|
||||||
if(null == in)
|
if(null == in)
|
||||||
((SpawnerInputStream)getInputStream()).close();
|
getInputStream().close();
|
||||||
if(null == out)
|
if(null == out)
|
||||||
((SpawnerOutputStream)getOutputStream()).close();
|
getOutputStream().close();
|
||||||
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
}
|
}
|
||||||
return status;
|
return status;
|
||||||
|
@ -211,11 +235,11 @@ public class Spawner extends Process {
|
||||||
// Close the streams on this side.
|
// Close the streams on this side.
|
||||||
try {
|
try {
|
||||||
if(null == err)
|
if(null == err)
|
||||||
((SpawnerInputStream)getErrorStream()).close();
|
getErrorStream().close();
|
||||||
if(null == in)
|
if(null == in)
|
||||||
((SpawnerInputStream)getInputStream()).close();
|
getInputStream().close();
|
||||||
if(null == out)
|
if(null == out)
|
||||||
((SpawnerOutputStream)getOutputStream()).close();
|
getOutputStream().close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
}
|
}
|
||||||
// Grace before using the heavy gone.
|
// Grace before using the heavy gone.
|
||||||
|
|
Loading…
Add table
Reference in a new issue