From 2471f7e1d3b83e3b3cd16165e2754914fdbef7cc Mon Sep 17 00:00:00 2001 From: Thomas Corbat Date: Wed, 9 Sep 2015 09:08:31 +0200 Subject: [PATCH] Bug 159803 - Console View Ignores EOF Added statement to send end of transmission (ASCII 4) before close for non-Windows PTY. Change-Id: If98848a833f7619ce93277d05d39f3ba986a3cf4 Signed-off-by: Thomas Corbat --- .../META-INF/MANIFEST.MF | 2 +- core/org.eclipse.cdt.core.native/pom.xml | 2 +- .../src/org/eclipse/cdt/utils/pty/PTY.java | 2 +- .../cdt/utils/pty/PTYOutputStream.java | 20 ++++++++++++++++++- 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/core/org.eclipse.cdt.core.native/META-INF/MANIFEST.MF b/core/org.eclipse.cdt.core.native/META-INF/MANIFEST.MF index 5eccb27a785..5a18807befa 100644 --- a/core/org.eclipse.cdt.core.native/META-INF/MANIFEST.MF +++ b/core/org.eclipse.cdt.core.native/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.cdt.core.native;singleton:=true -Bundle-Version: 5.8.0.qualifier +Bundle-Version: 5.9.0.qualifier Bundle-Activator: org.eclipse.cdt.internal.core.natives.CNativePlugin Bundle-Vendor: %providerName Bundle-Localization: plugin diff --git a/core/org.eclipse.cdt.core.native/pom.xml b/core/org.eclipse.cdt.core.native/pom.xml index e99396a147f..0cbb43ff788 100644 --- a/core/org.eclipse.cdt.core.native/pom.xml +++ b/core/org.eclipse.cdt.core.native/pom.xml @@ -11,7 +11,7 @@ ../../pom.xml - 5.8.0-SNAPSHOT + 5.9.0-SNAPSHOT org.eclipse.cdt.core.native eclipse-plugin diff --git a/core/org.eclipse.cdt.core.native/src/org/eclipse/cdt/utils/pty/PTY.java b/core/org.eclipse.cdt.core.native/src/org/eclipse/cdt/utils/pty/PTY.java index abef9e9e54f..3438e30997d 100644 --- a/core/org.eclipse.cdt.core.native/src/org/eclipse/cdt/utils/pty/PTY.java +++ b/core/org.eclipse.cdt.core.native/src/org/eclipse/cdt/utils/pty/PTY.java @@ -150,7 +150,7 @@ public class PTY { } in = new PTYInputStream(new MasterFD()); - out = new PTYOutputStream(new MasterFD()); + out = new PTYOutputStream(new MasterFD(), !isWinPTY); } /** diff --git a/core/org.eclipse.cdt.core.native/src/org/eclipse/cdt/utils/pty/PTYOutputStream.java b/core/org.eclipse.cdt.core.native/src/org/eclipse/cdt/utils/pty/PTYOutputStream.java index 8255597c43a..f5335c18375 100644 --- a/core/org.eclipse.cdt.core.native/src/org/eclipse/cdt/utils/pty/PTYOutputStream.java +++ b/core/org.eclipse.cdt.core.native/src/org/eclipse/cdt/utils/pty/PTYOutputStream.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2014 QNX Software Systems and others. + * Copyright (c) 2000, 2015 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 @@ -18,6 +18,9 @@ import org.eclipse.cdt.utils.pty.PTY.MasterFD; public class PTYOutputStream extends OutputStream { + private static final byte EOT = '\4'; + private boolean sendEotBeforeClose = false; + MasterFD master; /** @@ -25,7 +28,19 @@ public class PTYOutputStream extends OutputStream { * @param fd file descriptor. */ public PTYOutputStream(MasterFD fd) { + this(fd, false); + } + + /** + * From a Unix valid file descriptor set a Reader. + * @param fd file descriptor. + * @param sendEotBeforeClose flags the stream to send an EOT character + * before closing the stream to signalize end of stream. + * @since 5.9 + */ + public PTYOutputStream(MasterFD fd, boolean sendEotBeforeClose) { master = fd; + this.sendEotBeforeClose = sendEotBeforeClose; } /** @@ -69,6 +84,9 @@ public class PTYOutputStream extends OutputStream { public void close() throws IOException { if (master.getFD() == -1) return; + if (sendEotBeforeClose) { + write(EOT); + } int status = close0(master.getFD()); if (status == -1) throw new IOException("close error"); //$NON-NLS-1$