[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[cdt-patch] Fix PR 42571 for the CDT/Core PTY streams
|
Index: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/ChangeLog,v
retrieving revision 1.142
diff -u -r1.142 ChangeLog
--- ChangeLog 5 Sep 2003 15:23:12 -0000 1.142
+++ ChangeLog 5 Sep 2003 16:20:41 -0000
@@ -1,3 +1,12 @@
+2003-09-05 Alain Magloire
+
+ The PTY classes are using one instance of the master fd for Input/Output/Error
+ Streams. We need to wrap the fd access, to not throw IOException on multiple close.
+
+ * utils/org/eclipse/cdt/utils/pty/PTY.java
+ * utils/org/eclipse/cdt/utils/pty/PTYInputStream.java
+ * utils/org/eclipse/cdt/utils/pty/PTYOutputStream.java
+
2003-09-04 Hoda Amer
- Added references to variables in solution of bug#42453:Expression result types not computed
- Solution to bug#42560: Class Cast Exception during Method definition
Index: utils/org/eclipse/cdt/utils/pty/PTY.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/pty/PTY.java,v
retrieving revision 1.3
diff -u -r1.3 PTY.java
--- utils/org/eclipse/cdt/utils/pty/PTY.java 7 Sep 2002 14:45:09 -0000 1.3
+++ utils/org/eclipse/cdt/utils/pty/PTY.java 5 Sep 2003 16:20:42 -0000
@@ -15,12 +15,27 @@
public class PTY {
String slave;
- public int master;
InputStream in;
OutputStream out;
+ int master;
private static boolean hasPTY;
-
+
+ /**
+ * The master fd is use on two streams. We need to wrap the fd
+ * so when stream.close() is call the other stream is disable.
+ */
+ public class MasterFD {
+
+ public int getFD() {
+ return master;
+ }
+
+ public void setFD(int fd) {
+ master = fd;
+ }
+ }
+
public PTY() throws IOException {
if (hasPTY) {
slave= forkpty();
@@ -29,8 +44,9 @@
if (slave == null) {
throw new IOException("Can not create pty");
}
- in = new PTYInputStream(master);
- out = new PTYOutputStream(master);
+
+ in = new PTYInputStream(new MasterFD());
+ out = new PTYOutputStream(new MasterFD());
}
public String getSlaveName() {
Index: utils/org/eclipse/cdt/utils/pty/PTYInputStream.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/pty/PTYInputStream.java,v
retrieving revision 1.2
diff -u -r1.2 PTYInputStream.java
--- utils/org/eclipse/cdt/utils/pty/PTYInputStream.java 17 Oct 2002 13:58:38 -0000 1.2
+++ utils/org/eclipse/cdt/utils/pty/PTYInputStream.java 5 Sep 2003 16:20:42 -0000
@@ -8,15 +8,18 @@
import java.io.InputStream;
import java.io.IOException;
+import org.eclipse.cdt.utils.pty.PTY.MasterFD;
+
class PTYInputStream extends InputStream {
- private int fd;
+
+ MasterFD master;
/**
* Fome a Unix valid file descriptor set a Reader.
* @param desc file descriptor.
*/
- public PTYInputStream(int fd) {
- this.fd = fd;
+ public PTYInputStream(MasterFD fd) {
+ master = fd;
}
/**
@@ -46,7 +49,7 @@
}
byte[] tmpBuf = new byte[len];
- len = read0(fd, tmpBuf, len);
+ len = read0(master.getFD(), tmpBuf, len);
if (len <= 0)
return -1;
@@ -59,12 +62,12 @@
* @exception IOException on error.
*/
public void close() throws IOException {
- if (fd == -1)
+ if (master.getFD() == -1)
return;
- int status = close0(fd);
+ int status = close0(master.getFD());
if (status == -1)
throw new IOException("close error");
- fd = -1;
+ master.setFD(-1);
}
private native int read0(int fd, byte[] buf, int len) throws IOException;
Index: utils/org/eclipse/cdt/utils/pty/PTYOutputStream.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/pty/PTYOutputStream.java,v
retrieving revision 1.2
diff -u -r1.2 PTYOutputStream.java
--- utils/org/eclipse/cdt/utils/pty/PTYOutputStream.java 17 Oct 2002 13:59:00 -0000 1.2
+++ utils/org/eclipse/cdt/utils/pty/PTYOutputStream.java 5 Sep 2003 16:20:42 -0000
@@ -8,15 +8,18 @@
import java.io.OutputStream;
import java.io.IOException;
+import org.eclipse.cdt.utils.pty.PTY.MasterFD;
+
public class PTYOutputStream extends OutputStream {
- private int fd;
+
+ MasterFD master;
/**
* Fome a Unix valid file descriptor set a Reader.
* @param desc file descriptor.
*/
- public PTYOutputStream(int fd) {
- this.fd = fd;
+ public PTYOutputStream(MasterFD fd) {
+ master = fd;
}
/**
@@ -37,7 +40,7 @@
}
byte[] tmpBuf = new byte[len];
System.arraycopy(b, off, tmpBuf, off, len);
- write0(fd, tmpBuf, len);
+ write0(master.getFD(), tmpBuf, len);
}
/**
* Implementation of read for the InputStream.
@@ -55,12 +58,12 @@
* @exception IOException on error.
*/
public void close() throws IOException {
- if (fd == -1)
+ if (master.getFD() == -1)
return;
- int status = close0(fd);
+ int status = close0(master.getFD());
if (status == -1)
throw new IOException("close error"); //$NON-NLS-1$
- fd = -1;
+ master.setFD(-1);
}
private native int write0(int fd, byte[] b, int len) throws IOException;