Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnton Leherbauer2010-02-17 11:48:28 +0000
committerAnton Leherbauer2010-02-17 11:48:28 +0000
commit6c5788f39976ac9f457d2c96f7c840c4b08ca6d2 (patch)
tree33f91ecce9a9d73a06ac37584dfc7d3d8d6a5b3b
parenta603dc072a82d5588c64ef9be2990aadca016da0 (diff)
downloadorg.eclipse.cdt-6c5788f39976ac9f457d2c96f7c840c4b08ca6d2.tar.gz
org.eclipse.cdt-6c5788f39976ac9f457d2c96f7c840c4b08ca6d2.tar.xz
org.eclipse.cdt-6c5788f39976ac9f457d2c96f7c840c4b08ca6d2.zip
Bug 248071 - Improved pty support for terminal emulation
Thanks go to Mirko Raner, Pawel Piech, James Blackburn, et al.
-rw-r--r--core/org.eclipse.cdt.core.linux.x86/META-INF/MANIFEST.MF5
-rw-r--r--core/org.eclipse.cdt.core.linux.x86/os/linux/x86/libpty.sobin8071 -> 8132 bytes
-rw-r--r--core/org.eclipse.cdt.core.linux.x86/os/linux/x86/libspawner.sobin15895 -> 16418 bytes
-rw-r--r--core/org.eclipse.cdt.core.linux.x86_64/META-INF/MANIFEST.MF5
-rw-r--r--core/org.eclipse.cdt.core.linux.x86_64/os/linux/x86_64/libpty.sobin10927 -> 10321 bytes
-rw-r--r--core/org.eclipse.cdt.core.linux.x86_64/os/linux/x86_64/libspawner.sobin20161 -> 20253 bytes
-rw-r--r--core/org.eclipse.cdt.core.linux/META-INF/MANIFEST.MF5
-rw-r--r--core/org.eclipse.cdt.core.linux/library/Makefile4
-rw-r--r--core/org.eclipse.cdt.core.linux/library/PTY.h13
-rw-r--r--core/org.eclipse.cdt.core.linux/library/Spawner.h4
-rw-r--r--core/org.eclipse.cdt.core.linux/library/exec0.h12
-rw-r--r--core/org.eclipse.cdt.core.linux/library/exec_pty.c57
-rw-r--r--core/org.eclipse.cdt.core.linux/library/exec_unix.c22
-rw-r--r--core/org.eclipse.cdt.core.linux/library/openpty.c32
-rw-r--r--core/org.eclipse.cdt.core.linux/library/openpty.h6
-rw-r--r--core/org.eclipse.cdt.core.linux/library/pfind.c33
-rw-r--r--core/org.eclipse.cdt.core.linux/library/pty.c28
-rw-r--r--core/org.eclipse.cdt.core.linux/library/spawner.c19
-rw-r--r--core/org.eclipse.cdt.core.macosx/META-INF/MANIFEST.MF5
-rw-r--r--core/org.eclipse.cdt.core.macosx/library/PTY.h13
-rw-r--r--core/org.eclipse.cdt.core.macosx/library/Spawner.h4
-rw-r--r--core/org.eclipse.cdt.core.macosx/library/exec0.h7
-rw-r--r--core/org.eclipse.cdt.core.macosx/library/exec_pty.c42
-rw-r--r--core/org.eclipse.cdt.core.macosx/library/openpty.c14
-rw-r--r--core/org.eclipse.cdt.core.macosx/library/openpty.h4
-rw-r--r--core/org.eclipse.cdt.core.macosx/library/pfind.c6
-rw-r--r--core/org.eclipse.cdt.core.macosx/library/pty.c26
-rw-r--r--core/org.eclipse.cdt.core.macosx/library/spawner.c18
-rw-r--r--core/org.eclipse.cdt.core.macosx/os/macosx/ppc/libpty.jnilibbin9896 -> 9484 bytes
-rw-r--r--core/org.eclipse.cdt.core.macosx/os/macosx/ppc/libspawner.jnilibbin20540 -> 19028 bytes
-rwxr-xr-xcore/org.eclipse.cdt.core.macosx/os/macosx/x86/libpty.jnilibbin13760 -> 9868 bytes
-rwxr-xr-xcore/org.eclipse.cdt.core.macosx/os/macosx/x86/libspawner.jnilibbin19472 -> 15596 bytes
-rw-r--r--core/org.eclipse.cdt.core.macosx/os/macosx/x86_64/libpty.jnilibbin9320 -> 9896 bytes
-rw-r--r--core/org.eclipse.cdt.core.macosx/os/macosx/x86_64/libspawner.jnilibbin14872 -> 19800 bytes
-rw-r--r--core/org.eclipse.cdt.core.solaris/META-INF/MANIFEST.MF5
-rw-r--r--core/org.eclipse.cdt.core.solaris/library/Makefile4
-rw-r--r--core/org.eclipse.cdt.core.solaris/library/PTY.h13
-rw-r--r--core/org.eclipse.cdt.core.solaris/library/Spawner.h4
-rw-r--r--core/org.eclipse.cdt.core.solaris/library/exec0.h8
-rw-r--r--core/org.eclipse.cdt.core.solaris/library/exec_pty.c50
-rw-r--r--core/org.eclipse.cdt.core.solaris/library/exec_unix.c20
-rw-r--r--core/org.eclipse.cdt.core.solaris/library/openpty.c7
-rw-r--r--core/org.eclipse.cdt.core.solaris/library/openpty.h5
-rw-r--r--core/org.eclipse.cdt.core.solaris/library/pfind.c42
-rw-r--r--core/org.eclipse.cdt.core.solaris/library/pty.c27
-rw-r--r--core/org.eclipse.cdt.core.solaris/library/spawner.c18
-rw-r--r--core/org.eclipse.cdt.core.solaris/os/solaris/sparc/libpty.sobin9872 -> 10608 bytes
-rw-r--r--core/org.eclipse.cdt.core.solaris/os/solaris/sparc/libspawner.sobin19428 -> 21264 bytes
-rw-r--r--core/org.eclipse.cdt.core.win32/META-INF/MANIFEST.MF5
-rw-r--r--core/org.eclipse.cdt.core.win32/library/Spawner.h9
-rw-r--r--core/org.eclipse.cdt.core.win32/library/Win32ProcessEx.c4
-rw-r--r--core/org.eclipse.cdt.core.win32/os/win32/x86/spawner.dllbin39679 -> 39679 bytes
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CCorePluginResources.properties3
-rw-r--r--core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/pty/PTY.java92
-rw-r--r--core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/spawner/Spawner.java9
55 files changed, 520 insertions, 189 deletions
diff --git a/core/org.eclipse.cdt.core.linux.x86/META-INF/MANIFEST.MF b/core/org.eclipse.cdt.core.linux.x86/META-INF/MANIFEST.MF
index b187d90e64..c05242b3a2 100644
--- a/core/org.eclipse.cdt.core.linux.x86/META-INF/MANIFEST.MF
+++ b/core/org.eclipse.cdt.core.linux.x86/META-INF/MANIFEST.MF
@@ -2,7 +2,8 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %fragmentName.linux.x86
Bundle-SymbolicName: org.eclipse.cdt.core.linux.x86;singleton:=true
-Bundle-Version: 5.1.0.qualifier
+Bundle-Version: 5.2.0.qualifier
Bundle-Vendor: %providerName
-Fragment-Host: org.eclipse.cdt.core;bundle-version="[5.0.0,6.0.0)"
+Fragment-Host: org.eclipse.cdt.core;bundle-version="[5.2.0,6.0.0)"
Bundle-Localization: plugin
+Eclipse-PlatformFilter: (&(osgi.os=linux)(osgi.arch=x86))
diff --git a/core/org.eclipse.cdt.core.linux.x86/os/linux/x86/libpty.so b/core/org.eclipse.cdt.core.linux.x86/os/linux/x86/libpty.so
index 43496de101..60088bca3f 100644
--- a/core/org.eclipse.cdt.core.linux.x86/os/linux/x86/libpty.so
+++ b/core/org.eclipse.cdt.core.linux.x86/os/linux/x86/libpty.so
Binary files differ
diff --git a/core/org.eclipse.cdt.core.linux.x86/os/linux/x86/libspawner.so b/core/org.eclipse.cdt.core.linux.x86/os/linux/x86/libspawner.so
index 40a3e39b85..b6fb6323f3 100644
--- a/core/org.eclipse.cdt.core.linux.x86/os/linux/x86/libspawner.so
+++ b/core/org.eclipse.cdt.core.linux.x86/os/linux/x86/libspawner.so
Binary files differ
diff --git a/core/org.eclipse.cdt.core.linux.x86_64/META-INF/MANIFEST.MF b/core/org.eclipse.cdt.core.linux.x86_64/META-INF/MANIFEST.MF
index 81b7b5d0f1..c9b71bda20 100644
--- a/core/org.eclipse.cdt.core.linux.x86_64/META-INF/MANIFEST.MF
+++ b/core/org.eclipse.cdt.core.linux.x86_64/META-INF/MANIFEST.MF
@@ -2,7 +2,8 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %fragmentName.linux.x86_64
Bundle-SymbolicName: org.eclipse.cdt.core.linux.x86_64;singleton:=true
-Bundle-Version: 5.1.0.qualifier
+Bundle-Version: 5.2.0.qualifier
Bundle-Vendor: %providerName
-Fragment-Host: org.eclipse.cdt.core;bundle-version="[5.0.0,6.0.0)"
+Fragment-Host: org.eclipse.cdt.core;bundle-version="[5.2.0,6.0.0)"
Bundle-Localization: plugin
+Eclipse-PlatformFilter: (&(osgi.os=linux)(osgi.arch=x86_64))
diff --git a/core/org.eclipse.cdt.core.linux.x86_64/os/linux/x86_64/libpty.so b/core/org.eclipse.cdt.core.linux.x86_64/os/linux/x86_64/libpty.so
index 36aaff7328..3891b193a4 100644
--- a/core/org.eclipse.cdt.core.linux.x86_64/os/linux/x86_64/libpty.so
+++ b/core/org.eclipse.cdt.core.linux.x86_64/os/linux/x86_64/libpty.so
Binary files differ
diff --git a/core/org.eclipse.cdt.core.linux.x86_64/os/linux/x86_64/libspawner.so b/core/org.eclipse.cdt.core.linux.x86_64/os/linux/x86_64/libspawner.so
index 265ae37b10..d7d2e45689 100644
--- a/core/org.eclipse.cdt.core.linux.x86_64/os/linux/x86_64/libspawner.so
+++ b/core/org.eclipse.cdt.core.linux.x86_64/os/linux/x86_64/libspawner.so
Binary files differ
diff --git a/core/org.eclipse.cdt.core.linux/META-INF/MANIFEST.MF b/core/org.eclipse.cdt.core.linux/META-INF/MANIFEST.MF
index 2ee8842a09..c54d2ff7ea 100644
--- a/core/org.eclipse.cdt.core.linux/META-INF/MANIFEST.MF
+++ b/core/org.eclipse.cdt.core.linux/META-INF/MANIFEST.MF
@@ -2,9 +2,10 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %fragmentName.linux
Bundle-SymbolicName: org.eclipse.cdt.core.linux; singleton:=true
-Bundle-Version: 5.1.0.qualifier
+Bundle-Version: 5.2.0.qualifier
Bundle-ClassPath: cdt_linux.jar
Bundle-Vendor: %providerName
-Fragment-Host: org.eclipse.cdt.core;bundle-version="[5.0.0,6.0.0)"
+Fragment-Host: org.eclipse.cdt.core;bundle-version="[5.2.0,6.0.0)"
Bundle-Localization: plugin
Bundle-RequiredExecutionEnvironment: J2SE-1.4
+Eclipse-PlatformFilter: (osgi.os=linux)
diff --git a/core/org.eclipse.cdt.core.linux/library/Makefile b/core/org.eclipse.cdt.core.linux/library/Makefile
index 78a65c2f1e..6e67977b98 100644
--- a/core/org.eclipse.cdt.core.linux/library/Makefile
+++ b/core/org.eclipse.cdt.core.linux/library/Makefile
@@ -33,11 +33,11 @@ rebuild: clean all
$(LIB_NAME_FULL_SPAWNER) : $(OBJS_SPAWNER)
mkdir -p $(INSTALL_DIR)
- $(CC) -g -shared -Wl,-soname,$(LIB_NAME_SPAWNER) -o $(LIB_NAME_FULL_SPAWNER) $(OBJS_SPAWNER) -lc
+ $(CC) -g -shared -Wl,-soname,$(LIB_NAME_SPAWNER) $(LDFLAGS) -o $(LIB_NAME_FULL_SPAWNER) $(OBJS_SPAWNER) -lc
$(LIB_NAME_FULL_PTY): $(OBJS_PTY)
mkdir -p $(INSTALL_DIR)
- $(CC) -g -shared -Wl,-soname,$(LIB_NAME_PTY) -o $(LIB_NAME_FULL_PTY) $(OBJS_PTY)
+ $(CC) -g -shared -Wl,-soname,$(LIB_NAME_PTY) $(LDFLAGS) -o $(LIB_NAME_FULL_PTY) $(OBJS_PTY)
clean :
$(RM) $(OBJS_SPAWNER) $(LIB_NAME_FULL_SPAWNER)
diff --git a/core/org.eclipse.cdt.core.linux/library/PTY.h b/core/org.eclipse.cdt.core.linux/library/PTY.h
index 46a8dd9b62..f717942a01 100644
--- a/core/org.eclipse.cdt.core.linux/library/PTY.h
+++ b/core/org.eclipse.cdt.core.linux/library/PTY.h
@@ -7,14 +7,21 @@
#ifdef __cplusplus
extern "C" {
#endif
-/* Inaccessible static: hasPTY */
/*
* Class: org_eclipse_cdt_utils_pty_PTY
* Method: openMaster
- * Signature: ()Ljava/lang/String;
+ * Signature: (Z)Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_org_eclipse_cdt_utils_pty_PTY_openMaster
- (JNIEnv *, jobject);
+ (JNIEnv *, jobject, jboolean);
+
+/*
+ * Class: org_eclipse_cdt_utils_pty_PTY
+ * Method: change_window_size
+ * Signature: (III)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_pty_PTY_change_1window_1size
+ (JNIEnv *, jobject, jint, jint, jint);
#ifdef __cplusplus
}
diff --git a/core/org.eclipse.cdt.core.linux/library/Spawner.h b/core/org.eclipse.cdt.core.linux/library/Spawner.h
index 272366bad7..02727f98a8 100644
--- a/core/org.eclipse.cdt.core.linux/library/Spawner.h
+++ b/core/org.eclipse.cdt.core.linux/library/Spawner.h
@@ -26,10 +26,10 @@ JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_exec1
/*
* Class: org_eclipse_cdt_utils_spawner_Spawner
* Method: exec2
- * Signature: ([Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;[ILjava/lang/String;I)I
+ * Signature: ([Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;[ILjava/lang/String;IZ)I
*/
JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_exec2
- (JNIEnv *, jobject, jobjectArray, jobjectArray, jstring, jintArray, jstring, jint);
+ (JNIEnv *, jobject, jobjectArray, jobjectArray, jstring, jintArray, jstring, jint, jboolean);
/*
* Class: org_eclipse_cdt_utils_spawner_Spawner
diff --git a/core/org.eclipse.cdt.core.linux/library/exec0.h b/core/org.eclipse.cdt.core.linux/library/exec0.h
index 0629d101cd..3033ec1a5a 100644
--- a/core/org.eclipse.cdt.core.linux/library/exec0.h
+++ b/core/org.eclipse.cdt.core.linux/library/exec0.h
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2002 - 2005 QNX Software Systems and others.
+ * Copyright (c) 2002, 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,8 @@
*
* Contributors:
* QNX Software Systems - initial API and implementation
+ * Wind River Systems, Inc.
+ * Mikhail Zabaluev (Nokia) - bug 82744
*******************************************************************************/
#include <unistd.h>
#include <sys/wait.h>
@@ -16,6 +18,12 @@
extern pid_t exec0(const char *path, char *const argv[],
char *const envp[], const char *dirpath,
- int channels[3] );
+ int channels[3]);
+
+
+extern pid_t exec_pty(const char *path, char *const argv[],
+ char *const envp[], const char *dirpath,
+ int channels[3], const char *pts_name, int fdm,
+ int console);
extern int wait0(pid_t pid);
diff --git a/core/org.eclipse.cdt.core.linux/library/exec_pty.c b/core/org.eclipse.cdt.core.linux/library/exec_pty.c
index 5098e39b8e..dd68615f0e 100644
--- a/core/org.eclipse.cdt.core.linux/library/exec_pty.c
+++ b/core/org.eclipse.cdt.core.linux/library/exec_pty.c
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2006 QNX Software Systems and others.
+ * Copyright (c) 2004, 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
@@ -8,8 +8,11 @@
* Contributors:
* QNX Software Systems - initial API and implementation
* Wind River Systems, Inc.
+ * Mikhail Zabaluev (Nokia) - bug 82744
+ * Mikhail Sennikovsky - bug 145737
*******************************************************************************/
#include "exec0.h"
+#include "openpty.h"
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
@@ -20,11 +23,11 @@
#include <termios.h>
/* from pfind.c */
-extern char *pfind(const char *name);
+extern char *pfind(const char *name, char * const envp[]);
pid_t
exec_pty(const char *path, char *const argv[], char *const envp[],
- const char *dirpath, int channels[3], const char *pts_name, int fdm)
+ const char *dirpath, int channels[3], const char *pts_name, int fdm, int console)
{
int pipe2[2];
pid_t childpid;
@@ -34,7 +37,7 @@ exec_pty(const char *path, char *const argv[], char *const envp[],
* We use pfind() to check that the program exists and is an executable.
* If not pass the error up. Also execve() wants a full path.
*/
- full_path = pfind(path);
+ full_path = pfind(path, envp);
if (full_path == NULL) {
fprintf(stderr, "Unable to find full path for \"%s\"\n", (path) ? path : "");
return -1;
@@ -43,7 +46,7 @@ exec_pty(const char *path, char *const argv[], char *const envp[],
/*
* Make sure we can create our pipes before forking.
*/
- if (channels != NULL) {
+ if (channels != NULL && console) {
if (pipe(pipe2) < 0) {
fprintf(stderr, "%s(%d): returning due to error: %s\n", __FUNCTION__, __LINE__, strerror(errno));
free(full_path);
@@ -64,6 +67,11 @@ exec_pty(const char *path, char *const argv[], char *const envp[],
if (channels != NULL) {
int fds;
+ if (!console && setsid() < 0) {
+ perror("setsid()");
+ return -1;
+ }
+
fds = ptys_open(fdm, pts_name);
if (fds < 0) {
fprintf(stderr, "%s(%d): returning due to error: %s\n", __FUNCTION__, __LINE__, strerror(errno));
@@ -71,17 +79,29 @@ exec_pty(const char *path, char *const argv[], char *const envp[],
}
/* Close the read end of pipe2 */
- if (close(pipe2[0]) == -1)
+ if (console && close(pipe2[0]) == -1) {
perror("close(pipe2[0]))");
+ }
/* close the master, no need in the child */
close(fdm);
- set_noecho(fds);
+ if (console) {
+ set_noecho(fds);
+ if (setpgid(getpid(), getpid()) < 0) {
+ perror("setpgid()");
+ return -1;
+ }
+ }
+
/* redirections */
dup2(fds, STDIN_FILENO); /* dup stdin */
dup2(fds, STDOUT_FILENO); /* dup stdout */
- dup2(pipe2[1], STDERR_FILENO); /* dup stderr */
+ if (console) {
+ dup2(pipe2[1], STDERR_FILENO); /* dup stderr */
+ } else {
+ dup2(fds, STDERR_FILENO); /* dup stderr */
+ }
close(fds); /* done with fds. */
}
@@ -94,8 +114,6 @@ exec_pty(const char *path, char *const argv[], char *const envp[],
close(fd++);
}
- setpgid(getpid(), getpid());
-
if (envp[0] == NULL) {
execv(full_path, argv);
} else {
@@ -105,17 +123,20 @@ exec_pty(const char *path, char *const argv[], char *const envp[],
_exit(127);
} else if (childpid != 0) { /* parent */
-
- set_noecho(fdm);
+ if (console) {
+ set_noecho(fdm);
+ }
if (channels != NULL) {
- /* close the write end of pipe1 */
- if (close(pipe2[1]) == -1)
- perror("close(pipe2[1])");
-
channels[0] = fdm; /* Input Stream. */
channels[1] = fdm; /* Output Stream. */
- channels[2] = pipe2[0]; /* stderr Stream. */
- //channels[2] = fdm; /* Input Stream. */
+ if (console) {
+ /* close the write end of pipe1 */
+ if (close(pipe2[1]) == -1)
+ perror("close(pipe2[1])");
+ channels[2] = pipe2[0]; /* stderr Stream. */
+ } else {
+ channels[2] = fdm; /* Error Stream. */
+ }
}
free(full_path);
diff --git a/core/org.eclipse.cdt.core.linux/library/exec_unix.c b/core/org.eclipse.cdt.core.linux/library/exec_unix.c
index 7949f3b900..ced7b744da 100644
--- a/core/org.eclipse.cdt.core.linux/library/exec_unix.c
+++ b/core/org.eclipse.cdt.core.linux/library/exec_unix.c
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2002, 2006 QNX Software Systems and others.
+ * Copyright (c) 2002, 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,7 +7,8 @@
*
* Contributors:
* QNX Software Systems - initial API and implementation
- * Wind River Systems, Inc.
+ * Wind River Systems, Inc.
+ * Mikhail Sennikovsky - bug 145737
*******************************************************************************/
#include "exec0.h"
#include <unistd.h>
@@ -19,7 +20,7 @@
#include <stdlib.h>
/* from pfind.c */
-extern char *pfind(const char *name);
+extern char *pfind(const char *name, char * const envp[]);
pid_t
exec0(const char *path, char *const argv[], char *const envp[],
@@ -33,7 +34,7 @@ exec0(const char *path, char *const argv[], char *const envp[],
* We use pfind() to check that the program exists and is an executable.
* If not pass the error up. Also execve() wants a full path.
*/
- full_path = pfind(path);
+ full_path = pfind(path, envp);
if (full_path == NULL) {
fprintf(stderr, "Unable to find full path for \"%s\"\n", (path) ? path : "");
return -1;
@@ -137,9 +138,18 @@ int wait0(pid_t pid)
int status;
int val = -1;
- if (pid < 0 || waitpid(pid, &status, 0) < 0)
+ if (pid < 0)
return -1;
-
+
+ for (;;) {
+ if (waitpid(pid, &status, 0) < 0) {
+ if (errno == EINTR) {
+ // interrupted system call - retry
+ continue;
+ }
+ }
+ break;
+ }
if (WIFEXITED(status)) {
val = WEXITSTATUS(status);
}
diff --git a/core/org.eclipse.cdt.core.linux/library/openpty.c b/core/org.eclipse.cdt.core.linux/library/openpty.c
index 3a86072122..818ca8e078 100644
--- a/core/org.eclipse.cdt.core.linux/library/openpty.c
+++ b/core/org.eclipse.cdt.core.linux/library/openpty.c
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2002 - 2005 QNX Software Systems and others.
+ * Copyright (c) 2002, 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,7 +7,13 @@
*
* Contributors:
* QNX Software Systems - initial API and implementation
+ * Wind River Systems, Inc.
+ * Mikhail Zabaluev (Nokia) - bug 82744
+ * Corey Ashford (IBM) - bug 272370, bug 272372
*******************************************************************************/
+
+/* _XOPEN_SOURCE is needed to bring in the header for ptsname */
+#define _XOPEN_SOURCE
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
@@ -20,7 +26,6 @@
#include <grp.h>
#include <stdlib.h>
-#include <stropts.h>
/**
* This is taken from R. W. Stevens book.
@@ -28,7 +33,7 @@
*/
int ptym_open (char *pts_name);
-int ptys_open (int fdm, char * pts_name);
+int ptys_open (int fdm, const char * pts_name);
void set_noecho(int fd);
int
@@ -105,7 +110,7 @@ ptym_open(char * pts_name)
}
int
-ptys_open(int fdm, char * pts_name)
+ptys_open(int fdm, const char * pts_name)
{
int fds;
/* following should allocate controlling terminal */
@@ -114,19 +119,12 @@ ptys_open(int fdm, char * pts_name)
close(fdm);
return -5;
}
-/*
- if (ioctl(fds, I_PUSH, "ptem") < 0) {
- printf("pterm:%s\n", strerror(errno));
- close(fdm);
- close(fds);
- return -6;
- }
- if (ioctl(fds, I_PUSH, "ldterm") < 0) {
- printf("ldterm %s\n", strerror(errno));
- close(fdm);
- close(fds);
- return -7;
+
+#if defined(TIOCSCTTY)
+ /* TIOCSCTTY is the BSD way to acquire a controlling terminal. */
+ if (ioctl(fds, TIOCSCTTY, (char *)0) < 0) {
+ // ignore error: this is expected in console-mode
}
-*/
+#endif
return fds;
}
diff --git a/core/org.eclipse.cdt.core.linux/library/openpty.h b/core/org.eclipse.cdt.core.linux/library/openpty.h
index a32845e84d..c6475faa8a 100644
--- a/core/org.eclipse.cdt.core.linux/library/openpty.h
+++ b/core/org.eclipse.cdt.core.linux/library/openpty.h
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2002 - 2005 QNX Software Systems and others.
+ * Copyright (c) 2002, 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,10 +7,12 @@
*
* Contributors:
* QNX Software Systems - initial API and implementation
+ * Wind River Systems, Inc.
+ * Mikhail Zabaluev (Nokia) - bug 82744
*******************************************************************************/
#ifndef _OPENPTY_H
#define _OPENPTY_H
int ptym_open (char *pts_name);
-int ptys_open (int fdm, char * pts_name);
+int ptys_open (int fdm, const char * pts_name);
void set_noecho(int fd);
#endif
diff --git a/core/org.eclipse.cdt.core.linux/library/pfind.c b/core/org.eclipse.cdt.core.linux/library/pfind.c
index c4621e843b..519c6c3307 100644
--- a/core/org.eclipse.cdt.core.linux/library/pfind.c
+++ b/core/org.eclipse.cdt.core.linux/library/pfind.c
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2002 - 2005 QNX Software Systems and others.
+ * Copyright (c) 2002, 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,9 @@
*
* Contributors:
* QNX Software Systems - initial API and implementation
+ * Wind River Systems, Inc.
+ * Mikhail Sennikovsky - bug 145737
+ * Everton Rufino Constantino (IBM) - bug 237611
*******************************************************************************/
/*
* pfind.c - Search for a binary in $PATH.
@@ -22,8 +25,26 @@
#define PATH_MAX 1024
#endif
+#define PATH_DEF "PATH="
+const int path_def_len = 5; /* strlen(PATH_DEF); */
-char * pfind(const char *name)
+char * path_val(char * const envp[])
+{
+ int i;
+ if (envp == NULL || envp[0] == NULL)
+ return getenv("PATH" );
+
+ for(i = 0; envp[i] != NULL; i++){
+ char* p = envp[i];
+ if(!strncmp(PATH_DEF, p, path_def_len)){
+ return p + path_def_len;
+ }
+ }
+
+ return NULL;
+}
+
+char * pfind(const char *name, char * const envp[])
{
char *tok;
char *sp;
@@ -38,14 +59,14 @@ char * pfind(const char *name)
/* For absolute name or name with a path, check if it is an executable. */
if (name[0] == '/' || name[0] == '.') {
- if (access(name, X_OK | R_OK) == 0) {
+ if (access(name, X_OK) == 0) {
return strdup(name);
}
return NULL;
}
/* Search in the PATH environment. */
- path = getenv("PATH" );
+ path = path_val( envp );
if (path == NULL || strlen(path) <= 0) {
fprintf(stderr, "Unable to get $PATH.\n");
@@ -59,7 +80,7 @@ char * pfind(const char *name)
while (tok != NULL) {
snprintf(fullpath, sizeof(fullpath) - 1, "%s/%s", tok, name);
- if (access(fullpath, X_OK | R_OK) == 0) {
+ if (access(fullpath, X_OK) == 0) {
free(path);
return strdup(fullpath);
}
@@ -78,7 +99,7 @@ int main(int argc, char **argv)
char *fullpath;
for (i=1; i<argc; i++) {
- fullpath = pfind(argv[i]);
+ fullpath = pfind(argv[i], NULL);
if (fullpath == NULL)
printf("Unable to find %s in $PATH.\n", argv[i]);
else
diff --git a/core/org.eclipse.cdt.core.linux/library/pty.c b/core/org.eclipse.cdt.core.linux/library/pty.c
index 37a7604457..5c1e8645e6 100644
--- a/core/org.eclipse.cdt.core.linux/library/pty.c
+++ b/core/org.eclipse.cdt.core.linux/library/pty.c
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2002 - 2005 QNX Software Systems and others.
+ * Copyright (c) 2002, 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,7 +7,9 @@
*
* Contributors:
* QNX Software Systems - initial API and implementation
+ * Wind River Systems, Inc.
*******************************************************************************/
+#include <sys/ioctl.h>
#include "PTY.h"
#include "openpty.h"
@@ -17,7 +19,7 @@
* Signature: ()I
*/
JNIEXPORT jstring JNICALL
-Java_org_eclipse_cdt_utils_pty_PTY_openMaster (JNIEnv *env, jobject jobj) {
+Java_org_eclipse_cdt_utils_pty_PTY_openMaster (JNIEnv *env, jobject jobj, jboolean console) {
jfieldID fid; /* Store the field ID */
jstring jstr = NULL;
int master = -1;
@@ -29,7 +31,9 @@ Java_org_eclipse_cdt_utils_pty_PTY_openMaster (JNIEnv *env, jobject jobj) {
master = ptym_open(line);
if (master >= 0) {
// turn off echo
- set_noecho(master);
+ if (console) {
+ set_noecho(master);
+ }
/* Get a reference to the obj's class */
cls = (*env)->GetObjectClass(env, jobj);
@@ -46,3 +50,21 @@ Java_org_eclipse_cdt_utils_pty_PTY_openMaster (JNIEnv *env, jobject jobj) {
}
return jstr;
}
+
+JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_pty_PTY_change_1window_1size
+ (JNIEnv *env, jobject jobj, jint fdm, jint width, jint height)
+{
+#ifdef TIOCGWINSZ
+ struct winsize win;
+
+ win.ws_col = width;
+ win.ws_row = height;
+ win.ws_xpixel = 0;
+ win.ws_ypixel = 0;
+
+ return ioctl(fdm, TIOCSWINSZ, &win);
+#else
+ return 0;
+#endif
+}
+
diff --git a/core/org.eclipse.cdt.core.linux/library/spawner.c b/core/org.eclipse.cdt.core.linux/library/spawner.c
index 0b74145a72..67b12b05b8 100644
--- a/core/org.eclipse.cdt.core.linux/library/spawner.c
+++ b/core/org.eclipse.cdt.core.linux/library/spawner.c
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2002, 2006 QNX Software Systems and others.
+ * Copyright (c) 2002, 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
@@ -8,6 +8,7 @@
* Contributors:
* QNX Software Systems - initial API and implementation
* Wind River Systems, Inc.
+ * Mikhail Zabaluev (Nokia) - bug 82744
*******************************************************************************/
#include <unistd.h>
#include <stdlib.h>
@@ -89,13 +90,13 @@ static void free_c_array(char **c_array)
*/
JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_exec2
(JNIEnv *env, jobject jobj, jobjectArray jcmd, jobjectArray jenv, jstring jdir, jintArray jchannels,
- jstring jslaveName, jint masterFD)
+ jstring jslaveName, jint masterFD, jboolean console)
{
jint *channels = (*env)->GetIntArrayElements(env, jchannels, 0);
const char *dirpath = (*env)->GetStringUTFChars(env, jdir, NULL);
const char *pts_name = (*env)->GetStringUTFChars(env, jslaveName, NULL);
- char **cmd;
- char **envp;
+ char **cmd = NULL;
+ char **envp = NULL;
int fd[3];
pid_t pid = -1;
@@ -119,7 +120,7 @@ JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_exec2
fprintf(stderr, "pts_name: %s\n", pts_name);
#endif
- pid = exec_pty(cmd[0], cmd, envp, dirpath, fd, pts_name, masterFD);
+ pid = exec_pty(cmd[0], cmd, envp, dirpath, fd, pts_name, masterFD, console);
if (pid < 0)
goto bail_out;
@@ -146,8 +147,8 @@ Java_org_eclipse_cdt_utils_spawner_Spawner_exec1(JNIEnv * env, jobject jobj,
jstring jdir)
{
const char *dirpath = (*env)->GetStringUTFChars(env, jdir, NULL);
- char **cmd;
- char **envp;
+ char **cmd = NULL;
+ char **envp = NULL;
pid_t pid = -1;
cmd = alloc_c_array(env, jcmd);
@@ -193,8 +194,8 @@ Java_org_eclipse_cdt_utils_spawner_Spawner_exec0(JNIEnv * env, jobject jobj,
{
jint *channels = (*env)->GetIntArrayElements(env, jchannels, 0);
const char *dirpath = (*env)->GetStringUTFChars(env, jdir, NULL);
- char **cmd;
- char **envp;
+ char **cmd = NULL;
+ char **envp = NULL;
int fd[3];
pid_t pid = -1;
diff --git a/core/org.eclipse.cdt.core.macosx/META-INF/MANIFEST.MF b/core/org.eclipse.cdt.core.macosx/META-INF/MANIFEST.MF
index 4d791c4309..9391a5985a 100644
--- a/core/org.eclipse.cdt.core.macosx/META-INF/MANIFEST.MF
+++ b/core/org.eclipse.cdt.core.macosx/META-INF/MANIFEST.MF
@@ -2,9 +2,10 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %fragmentName.macosx
Bundle-SymbolicName: org.eclipse.cdt.core.macosx; singleton:=true
-Bundle-Version: 5.1.0.qualifier
+Bundle-Version: 5.2.0.qualifier
Bundle-ClassPath: cdt_macosx.jar
Bundle-Vendor: %providerName
-Fragment-Host: org.eclipse.cdt.core;bundle-version="[5.0.0,6.0.0)"
+Fragment-Host: org.eclipse.cdt.core;bundle-version="[5.2.0,6.0.0)"
Bundle-Localization: plugin
Bundle-RequiredExecutionEnvironment: J2SE-1.4
+Eclipse-PlatformFilter: (osgi.os=macosx)
diff --git a/core/org.eclipse.cdt.core.macosx/library/PTY.h b/core/org.eclipse.cdt.core.macosx/library/PTY.h
index 46a8dd9b62..f717942a01 100644
--- a/core/org.eclipse.cdt.core.macosx/library/PTY.h
+++ b/core/org.eclipse.cdt.core.macosx/library/PTY.h
@@ -7,14 +7,21 @@
#ifdef __cplusplus
extern "C" {
#endif
-/* Inaccessible static: hasPTY */
/*
* Class: org_eclipse_cdt_utils_pty_PTY
* Method: openMaster
- * Signature: ()Ljava/lang/String;
+ * Signature: (Z)Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_org_eclipse_cdt_utils_pty_PTY_openMaster
- (JNIEnv *, jobject);
+ (JNIEnv *, jobject, jboolean);
+
+/*
+ * Class: org_eclipse_cdt_utils_pty_PTY
+ * Method: change_window_size
+ * Signature: (III)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_pty_PTY_change_1window_1size
+ (JNIEnv *, jobject, jint, jint, jint);
#ifdef __cplusplus
}
diff --git a/core/org.eclipse.cdt.core.macosx/library/Spawner.h b/core/org.eclipse.cdt.core.macosx/library/Spawner.h
index 272366bad7..02727f98a8 100644
--- a/core/org.eclipse.cdt.core.macosx/library/Spawner.h
+++ b/core/org.eclipse.cdt.core.macosx/library/Spawner.h
@@ -26,10 +26,10 @@ JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_exec1
/*
* Class: org_eclipse_cdt_utils_spawner_Spawner
* Method: exec2
- * Signature: ([Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;[ILjava/lang/String;I)I
+ * Signature: ([Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;[ILjava/lang/String;IZ)I
*/
JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_exec2
- (JNIEnv *, jobject, jobjectArray, jobjectArray, jstring, jintArray, jstring, jint);
+ (JNIEnv *, jobject, jobjectArray, jobjectArray, jstring, jintArray, jstring, jint, jboolean);
/*
* Class: org_eclipse_cdt_utils_spawner_Spawner
diff --git a/core/org.eclipse.cdt.core.macosx/library/exec0.h b/core/org.eclipse.cdt.core.macosx/library/exec0.h
index 8249da9566..fa23bd792b 100644
--- a/core/org.eclipse.cdt.core.macosx/library/exec0.h
+++ b/core/org.eclipse.cdt.core.macosx/library/exec0.h
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2002 - 2005 QNX Software Systems and others.
+ * Copyright (c) 2002, 2009 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,4 +18,9 @@ extern pid_t exec0(const char *path, char *const argv[],
char *const envp[], const char *dirpath,
int channels[3] );
+extern pid_t exec_pty(const char *path, char *const argv[],
+ char *const envp[], const char *dirpath,
+ int channels[3], const char *pts_name, int fdm,
+ int console);
+
extern int wait0(pid_t pid);
diff --git a/core/org.eclipse.cdt.core.macosx/library/exec_pty.c b/core/org.eclipse.cdt.core.macosx/library/exec_pty.c
index 55779c6a9d..47d36963a0 100644
--- a/core/org.eclipse.cdt.core.macosx/library/exec_pty.c
+++ b/core/org.eclipse.cdt.core.macosx/library/exec_pty.c
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2002 - 2005 QNX Software Systems and others.
+ * Copyright (c) 2002, 2009 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
@@ -9,6 +9,7 @@
* QNX Software Systems - initial API and implementation
*******************************************************************************/
#include "exec0.h"
+#include "openpty.h"
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
@@ -23,7 +24,7 @@ extern char *pfind(const char *name);
pid_t
exec_pty(const char *path, char *const argv[], char *const envp[],
- const char *dirpath, int channels[3], const char *pts_name, int fdm)
+ const char *dirpath, int channels[3], const char *pts_name, int fdm, int console)
{
int pipe2[2];
pid_t childpid;
@@ -42,7 +43,7 @@ exec_pty(const char *path, char *const argv[], char *const envp[],
/*
* Make sure we can create our pipes before forking.
*/
- if (channels != NULL) {
+ if (console && channels != NULL) {
if (pipe(pipe2) < 0) {
fprintf(stderr, "%s(%d): returning due to error: %s\n", __FUNCTION__, __LINE__, strerror(errno));
free(full_path);
@@ -63,6 +64,11 @@ exec_pty(const char *path, char *const argv[], char *const envp[],
if (channels != NULL) {
int fds;
+ if (!console && setsid() < 0) {
+ perror("setsid()");
+ return -1;
+ }
+
fds = ptys_open(fdm, pts_name);
if (fds < 0) {
fprintf(stderr, "%s(%d): returning due to error: %s\n", __FUNCTION__, __LINE__, strerror(errno));
@@ -70,17 +76,28 @@ exec_pty(const char *path, char *const argv[], char *const envp[],
}
/* Close the read end of pipe2 */
- if (close(pipe2[0]) == -1)
+ if (console && close(pipe2[0]) == -1) {
perror("close(pipe2[0]))");
+ }
/* close the master, no need in the child */
close(fdm);
- set_noecho(fds);
+ if (console) {
+ set_noecho(fds);
+ if (setpgid(getpid(), getpid()) < 0) {
+ perror("setpgid()");
+ return -1;
+ }
+ }
/* redirections */
dup2(fds, STDIN_FILENO); /* dup stdin */
dup2(fds, STDOUT_FILENO); /* dup stdout */
- dup2(pipe2[1], STDERR_FILENO); /* dup stderr */
+ if (console) {
+ dup2(pipe2[1], STDERR_FILENO); /* dup stderr */
+ } else {
+ dup2(fds, STDERR_FILENO); /* dup stderr */
+ }
close(fds); /* done with fds. */
}
@@ -103,16 +120,21 @@ exec_pty(const char *path, char *const argv[], char *const envp[],
} else if (childpid != 0) { /* parent */
- set_noecho(fdm);
+ if (console) {
+ set_noecho(fdm);
+ }
if (channels != NULL) {
/* close the write end of pipe1 */
- if (close(pipe2[1]) == -1)
+ if (console && close(pipe2[1]) == -1)
perror("close(pipe2[1])");
channels[0] = fdm; /* Input Stream. */
channels[1] = fdm; /* Output Stream. */
- channels[2] = pipe2[0]; /* stderr Stream. */
- //channels[2] = fdm; /* Input Stream. */
+ if (console) { /* stderr Stream. */
+ channels[2] = pipe2[0];
+ } else {
+ channels[2] = fdm;
+ }
}
free(full_path);
diff --git a/core/org.eclipse.cdt.core.macosx/library/openpty.c b/core/org.eclipse.cdt.core.macosx/library/openpty.c
index c5c81967ab..0d720f578f 100644
--- a/core/org.eclipse.cdt.core.macosx/library/openpty.c
+++ b/core/org.eclipse.cdt.core.macosx/library/openpty.c
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2002 - 2005 QNX Software Systems and others.
+ * Copyright (c) 2002, 2009 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
@@ -28,7 +28,7 @@
*/
int ptym_open (char *pts_name);
-int ptys_open (int fdm, char * pts_name);
+int ptys_open (int fdm, const char * pts_name);
int
openpty(int *amaster, int *aslave, char *name, struct termios *termp, struct winsize *winp)
@@ -86,7 +86,7 @@ ptym_open(char * pts_name)
}
int
-ptys_open(int fdm, char * pts_name)
+ptys_open(int fdm, const char * pts_name)
{
int gid, fds;
struct group *grptr;
@@ -106,6 +106,14 @@ ptys_open(int fdm, char * pts_name)
close(fdm);
return -1;
}
+
+#if defined(TIOCSCTTY)
+ /* TIOCSCTTY is the BSD way to acquire a controlling terminal. */
+ if (ioctl(fds, TIOCSCTTY, (char *)0) < 0) {
+ // ignore error: this is expected in console-mode
+ }
+#endif
+
return fds;
}
diff --git a/core/org.eclipse.cdt.core.macosx/library/openpty.h b/core/org.eclipse.cdt.core.macosx/library/openpty.h
index a32845e84d..fd974da9bd 100644
--- a/core/org.eclipse.cdt.core.macosx/library/openpty.h
+++ b/core/org.eclipse.cdt.core.macosx/library/openpty.h
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2002 - 2005 QNX Software Systems and others.
+ * Copyright (c) 2002, 2009 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
@@ -11,6 +11,6 @@
#ifndef _OPENPTY_H
#define _OPENPTY_H
int ptym_open (char *pts_name);
-int ptys_open (int fdm, char * pts_name);
+int ptys_open (int fdm, const char * pts_name);
void set_noecho(int fd);
#endif
diff --git a/core/org.eclipse.cdt.core.macosx/library/pfind.c b/core/org.eclipse.cdt.core.macosx/library/pfind.c
index c4621e843b..b673c0e3ea 100644
--- a/core/org.eclipse.cdt.core.macosx/library/pfind.c
+++ b/core/org.eclipse.cdt.core.macosx/library/pfind.c
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2002 - 2005 QNX Software Systems and others.
+ * Copyright (c) 2002, 2009 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
@@ -38,7 +38,7 @@ char * pfind(const char *name)
/* For absolute name or name with a path, check if it is an executable. */
if (name[0] == '/' || name[0] == '.') {
- if (access(name, X_OK | R_OK) == 0) {
+ if (access(name, X_OK) == 0) {
return strdup(name);
}
return NULL;
@@ -59,7 +59,7 @@ char * pfind(const char *name)
while (tok != NULL) {
snprintf(fullpath, sizeof(fullpath) - 1, "%s/%s", tok, name);
- if (access(fullpath, X_OK | R_OK) == 0) {
+ if (access(fullpath, X_OK) == 0) {
free(path);
return strdup(fullpath);
}
diff --git a/core/org.eclipse.cdt.core.macosx/library/pty.c b/core/org.eclipse.cdt.core.macosx/library/pty.c
index a8077b0a5a..e7c23e8fbc 100644
--- a/core/org.eclipse.cdt.core.macosx/library/pty.c
+++ b/core/org.eclipse.cdt.core.macosx/library/pty.c
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2002 - 2005 QNX Software Systems and others.
+ * Copyright (c) 2002, 2009 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
@@ -17,7 +17,7 @@
* Signature: ()I
*/
JNIEXPORT jstring JNICALL
-Java_org_eclipse_cdt_utils_pty_PTY_openMaster (JNIEnv *env, jobject jobj) {
+Java_org_eclipse_cdt_utils_pty_PTY_openMaster (JNIEnv *env, jobject jobj, jboolean console) {
jfieldID fid; /* Store the field ID */
jstring jstr = NULL;
int master = -1;
@@ -28,6 +28,11 @@ Java_org_eclipse_cdt_utils_pty_PTY_openMaster (JNIEnv *env, jobject jobj) {
master = ptym_open(line);
if (master >= 0) {
+ if (console) {
+ // turn off echo
+ set_noecho(master);
+ }
+
/* Get a reference to the obj's class */
cls = (*env)->GetObjectClass(env, jobj);
@@ -43,3 +48,20 @@ Java_org_eclipse_cdt_utils_pty_PTY_openMaster (JNIEnv *env, jobject jobj) {
}
return jstr;
}
+
+JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_pty_PTY_change_1window_1size
+ (JNIEnv *env, jobject jobj, jint fdm, jint width, jint height)
+{
+#ifdef TIOCGWINSZ
+ struct winsize win;
+
+ win.ws_col = width;
+ win.ws_row = height;
+ win.ws_xpixel = 0;
+ win.ws_ypixel = 0;
+
+ return ioctl(fdm, TIOCSWINSZ, &win);
+#else
+ return 0;
+#endif
+}
diff --git a/core/org.eclipse.cdt.core.macosx/library/spawner.c b/core/org.eclipse.cdt.core.macosx/library/spawner.c
index f9ee8f6354..99f7fde8ca 100644
--- a/core/org.eclipse.cdt.core.macosx/library/spawner.c
+++ b/core/org.eclipse.cdt.core.macosx/library/spawner.c
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2002 - 2005 QNX Software Systems and others.
+ * Copyright (c) 2002, 2009 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
@@ -88,13 +88,13 @@ static void free_c_array(char **c_array)
*/
JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_exec2
(JNIEnv *env, jobject jobj, jobjectArray jcmd, jobjectArray jenv, jstring jdir, jintArray jchannels,
- jstring jslaveName, jint masterFD)
+ jstring jslaveName, jint masterFD, jboolean console)
{
jint *channels = (*env)->GetIntArrayElements(env, jchannels, 0);
const char *dirpath = (*env)->GetStringUTFChars(env, jdir, NULL);
const char *pts_name = (*env)->GetStringUTFChars(env, jslaveName, NULL);
- char **cmd;
- char **envp;
+ char **cmd = NULL;
+ char **envp = NULL;
int fd[3];
pid_t pid = -1;
@@ -118,7 +118,7 @@ JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_exec2
fprintf(stderr, "pts_name: %s\n", pts_name);
#endif
- pid = exec_pty(cmd[0], cmd, envp, dirpath, fd, pts_name, masterFD);
+ pid = exec_pty(cmd[0], cmd, envp, dirpath, fd, pts_name, masterFD, console);
if (pid < 0)
goto bail_out;
@@ -144,8 +144,8 @@ Java_org_eclipse_cdt_utils_spawner_Spawner_exec1(JNIEnv * env, jobject jobj,
jstring jdir)
{
const char *dirpath = (*env)->GetStringUTFChars(env, jdir, NULL);
- char **cmd;
- char **envp;
+ char **cmd = NULL;
+ char **envp = NULL;
pid_t pid = -1;
cmd = alloc_c_array(env, jcmd);
@@ -191,8 +191,8 @@ Java_org_eclipse_cdt_utils_spawner_Spawner_exec0(JNIEnv * env, jobject jobj,
{
jint *channels = (*env)->GetIntArrayElements(env, jchannels, 0);
const char *dirpath = (*env)->GetStringUTFChars(env, jdir, NULL);
- char **cmd;
- char **envp;
+ char **cmd = NULL;
+ char **envp = NULL;
int fd[3];
pid_t pid = -1;
diff --git a/core/org.eclipse.cdt.core.macosx/os/macosx/ppc/libpty.jnilib b/core/org.eclipse.cdt.core.macosx/os/macosx/ppc/libpty.jnilib
index 6eea7b33b5..af67897f8c 100644
--- a/core/org.eclipse.cdt.core.macosx/os/macosx/ppc/libpty.jnilib
+++ b/core/org.eclipse.cdt.core.macosx/os/macosx/ppc/libpty.jnilib
Binary files differ
diff --git a/core/org.eclipse.cdt.core.macosx/os/macosx/ppc/libspawner.jnilib b/core/org.eclipse.cdt.core.macosx/os/macosx/ppc/libspawner.jnilib
index 4ab7955d32..837cde95f0 100644
--- a/core/org.eclipse.cdt.core.macosx/os/macosx/ppc/libspawner.jnilib
+++ b/core/org.eclipse.cdt.core.macosx/os/macosx/ppc/libspawner.jnilib
Binary files differ
diff --git a/core/org.eclipse.cdt.core.macosx/os/macosx/x86/libpty.jnilib b/core/org.eclipse.cdt.core.macosx/os/macosx/x86/libpty.jnilib
index 42d4cee025..688d81dffc 100755
--- a/core/org.eclipse.cdt.core.macosx/os/macosx/x86/libpty.jnilib
+++ b/core/org.eclipse.cdt.core.macosx/os/macosx/x86/libpty.jnilib
Binary files differ
diff --git a/core/org.eclipse.cdt.core.macosx/os/macosx/x86/libspawner.jnilib b/core/org.eclipse.cdt.core.macosx/os/macosx/x86/libspawner.jnilib
index a35c8c38c1..45eb1bc02a 100755
--- a/core/org.eclipse.cdt.core.macosx/os/macosx/x86/libspawner.jnilib
+++ b/core/org.eclipse.cdt.core.macosx/os/macosx/x86/libspawner.jnilib
Binary files differ
diff --git a/core/org.eclipse.cdt.core.macosx/os/macosx/x86_64/libpty.jnilib b/core/org.eclipse.cdt.core.macosx/os/macosx/x86_64/libpty.jnilib
index 16909aecfb..e0db015894 100644
--- a/core/org.eclipse.cdt.core.macosx/os/macosx/x86_64/libpty.jnilib
+++ b/core/org.eclipse.cdt.core.macosx/os/macosx/x86_64/libpty.jnilib
Binary files differ
diff --git a/core/org.eclipse.cdt.core.macosx/os/macosx/x86_64/libspawner.jnilib b/core/org.eclipse.cdt.core.macosx/os/macosx/x86_64/libspawner.jnilib
index b0c41c78d7..af9d33962c 100644
--- a/core/org.eclipse.cdt.core.macosx/os/macosx/x86_64/libspawner.jnilib
+++ b/core/org.eclipse.cdt.core.macosx/os/macosx/x86_64/libspawner.jnilib
Binary files differ
diff --git a/core/org.eclipse.cdt.core.solaris/META-INF/MANIFEST.MF b/core/org.eclipse.cdt.core.solaris/META-INF/MANIFEST.MF
index 25e962f55a..92d3b1e3cf 100644
--- a/core/org.eclipse.cdt.core.solaris/META-INF/MANIFEST.MF
+++ b/core/org.eclipse.cdt.core.solaris/META-INF/MANIFEST.MF
@@ -2,9 +2,10 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %fragmentName.solaris
Bundle-SymbolicName: org.eclipse.cdt.core.solaris; singleton:=true
-Bundle-Version: 5.1.0.qualifier
+Bundle-Version: 5.2.0.qualifier
Bundle-ClassPath: cdt_solaris.jar
Bundle-Vendor: %providerName
-Fragment-Host: org.eclipse.cdt.core;bundle-version="[5.0.0,6.0.0)"
+Fragment-Host: org.eclipse.cdt.core;bundle-version="[5.2.0,6.0.0)"
Bundle-Localization: plugin
Bundle-RequiredExecutionEnvironment: J2SE-1.4
+Eclipse-PlatformFilter: (&(osgi.os=solaris)(osgi.arch=sparc))
diff --git a/core/org.eclipse.cdt.core.solaris/library/Makefile b/core/org.eclipse.cdt.core.solaris/library/Makefile
index 75d3a3cd5b..8c074ca763 100644
--- a/core/org.eclipse.cdt.core.solaris/library/Makefile
+++ b/core/org.eclipse.cdt.core.solaris/library/Makefile
@@ -19,10 +19,10 @@ OBJS_PTY=openpty.o pty.o ptyio.o
all: $(LIB_NAME_FULL_SPAWNER) $(LIB_NAME_FULL_PTY)
$(LIB_NAME_FULL_SPAWNER): $(OBJS_SPAWNER)
- $(CC) -g -shared -Wl,-soname,$(LIB_NAME_SPAWNER) -o $(LIB_NAME_FULL_SPAWNER) $(OBJS_SPAWNER) -lc
+ $(CC) -g -shared -static-libgcc -o $(LIB_NAME_FULL_SPAWNER) $(OBJS_SPAWNER) -lc
$(LIB_NAME_FULL_PTY): $(OBJS_PTY)
- $(CC) -g -shared -Wl,-soname,$(LIB_NAME_PTY) -o $(LIB_NAME_FULL_PTY) $(OBJS_PTY)
+ $(CC) -g -shared -static-libgcc -o $(LIB_NAME_FULL_PTY) $(OBJS_PTY)
clean :
$(RM) $(OBJS_SPAWNER) $(LIB_NAME_FULL_SPAWNER)
diff --git a/core/org.eclipse.cdt.core.solaris/library/PTY.h b/core/org.eclipse.cdt.core.solaris/library/PTY.h
index 46a8dd9b62..f717942a01 100644
--- a/core/org.eclipse.cdt.core.solaris/library/PTY.h
+++ b/core/org.eclipse.cdt.core.solaris/library/PTY.h
@@ -7,14 +7,21 @@
#ifdef __cplusplus
extern "C" {
#endif
-/* Inaccessible static: hasPTY */
/*
* Class: org_eclipse_cdt_utils_pty_PTY
* Method: openMaster
- * Signature: ()Ljava/lang/String;
+ * Signature: (Z)Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_org_eclipse_cdt_utils_pty_PTY_openMaster
- (JNIEnv *, jobject);
+ (JNIEnv *, jobject, jboolean);
+
+/*
+ * Class: org_eclipse_cdt_utils_pty_PTY
+ * Method: change_window_size
+ * Signature: (III)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_pty_PTY_change_1window_1size
+ (JNIEnv *, jobject, jint, jint, jint);
#ifdef __cplusplus
}
diff --git a/core/org.eclipse.cdt.core.solaris/library/Spawner.h b/core/org.eclipse.cdt.core.solaris/library/Spawner.h
index 272366bad7..02727f98a8 100644
--- a/core/org.eclipse.cdt.core.solaris/library/Spawner.h
+++ b/core/org.eclipse.cdt.core.solaris/library/Spawner.h
@@ -26,10 +26,10 @@ JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_exec1
/*
* Class: org_eclipse_cdt_utils_spawner_Spawner
* Method: exec2
- * Signature: ([Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;[ILjava/lang/String;I)I
+ * Signature: ([Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;[ILjava/lang/String;IZ)I
*/
JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_exec2
- (JNIEnv *, jobject, jobjectArray, jobjectArray, jstring, jintArray, jstring, jint);
+ (JNIEnv *, jobject, jobjectArray, jobjectArray, jstring, jintArray, jstring, jint, jboolean);
/*
* Class: org_eclipse_cdt_utils_spawner_Spawner
diff --git a/core/org.eclipse.cdt.core.solaris/library/exec0.h b/core/org.eclipse.cdt.core.solaris/library/exec0.h
index fc8f2479b0..f2aaca6317 100644
--- a/core/org.eclipse.cdt.core.solaris/library/exec0.h
+++ b/core/org.eclipse.cdt.core.solaris/library/exec0.h
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2002 - 2005 QNX Software Systems and others.
+ * Copyright (c) 2002, 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, Inc.
*******************************************************************************/
#include <unistd.h>
#include <sys/wait.h>
@@ -17,4 +18,9 @@ extern pid_t exec0(const char *path, char *const argv[],
char *const envp[], const char *dirpath,
int channels[3] );
+extern pid_t exec_pty(const char *path, char *const argv[],
+ char *const envp[], const char *dirpath,
+ int channels[3], const char *pts_name, int fdm,
+ int console);
+
extern int wait0(pid_t pid);
diff --git a/core/org.eclipse.cdt.core.solaris/library/exec_pty.c b/core/org.eclipse.cdt.core.solaris/library/exec_pty.c
index f943d8afa6..87241989a0 100644
--- a/core/org.eclipse.cdt.core.solaris/library/exec_pty.c
+++ b/core/org.eclipse.cdt.core.solaris/library/exec_pty.c
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2002, 2006 QNX Software Systems and others.
+ * Copyright (c) 2002, 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
@@ -8,8 +8,10 @@
* Contributors:
* QNX Software Systems - initial API and implementation
* Wind River Systems, Inc.
+ * Mikhail Sennikovsky - bug 145737
*******************************************************************************/
#include "exec0.h"
+#include "openpty.h"
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
@@ -22,11 +24,11 @@
#include <sys/ioctl.h>
/* from pfind.c */
-extern char *pfind(const char *name);
+extern char *pfind(const char *name, char * const envp[]);
pid_t
exec_pty(const char *path, char *const argv[], char *const envp[],
- const char *dirpath, int channels[3], const char *pts_name, int fdm)
+ const char *dirpath, int channels[3], const char *pts_name, int fdm, int console)
{
int pipe2[2];
pid_t childpid;
@@ -36,7 +38,7 @@ exec_pty(const char *path, char *const argv[], char *const envp[],
* We use pfind() to check that the program exists and is an executable.
* If not pass the error up. Also execve() wants a full path.
*/
- full_path = pfind(path);
+ full_path = pfind(path, envp);
if (full_path == NULL) {
fprintf(stderr, "Unable to find full path for \"%s\"\n", (path) ? path : "");
return -1;
@@ -45,7 +47,7 @@ exec_pty(const char *path, char *const argv[], char *const envp[],
/*
* Make sure we can create our pipes before forking.
*/
- if (channels != NULL) {
+ if (console && channels != NULL) {
if (pipe(pipe2) < 0) {
fprintf(stderr, "%s(%d): returning due to error: %s\n", __FUNCTION__, __LINE__, strerror(errno));
free(full_path);
@@ -66,6 +68,11 @@ exec_pty(const char *path, char *const argv[], char *const envp[],
if (channels != NULL) {
int fds;
+ if (!console && setsid() < 0) {
+ perror("setsid()");
+ return -1;
+ }
+
fds = ptys_open(fdm, pts_name);
if (fds < 0) {
fprintf(stderr, "%s(%d): returning due to error: %s\n", __FUNCTION__, __LINE__, strerror(errno));
@@ -73,17 +80,29 @@ exec_pty(const char *path, char *const argv[], char *const envp[],
}
/* Close the read end of pipe2 */
- if (close(pipe2[0]) == -1)
+ if (console && close(pipe2[0]) == -1) {
perror("close(pipe2[0]))");
+ }
/* close the master, no need in the child */
close(fdm);
- set_noecho(fds);
+ if (console) {
+ set_noecho(fds);
+ if (setpgid(getpid(), getpid()) < 0) {
+ perror("setpgid()");
+ return -1;
+ }
+ }
+
/* redirections */
dup2(fds, STDIN_FILENO); /* dup stdin */
dup2(fds, STDOUT_FILENO); /* dup stdout */
- dup2(pipe2[1], STDERR_FILENO); /* dup stderr */
+ if (console) {
+ dup2(pipe2[1], STDERR_FILENO); /* dup stderr */
+ } else {
+ dup2(fds, STDERR_FILENO); /* dup stderr */
+ }
close(fds); /* done with fds. */
}
@@ -96,8 +115,6 @@ exec_pty(const char *path, char *const argv[], char *const envp[],
close(fd++);
}
- setpgid(getpid(), getpid());
-
if (envp[0] == NULL) {
execv(full_path, argv);
} else {
@@ -109,16 +126,21 @@ exec_pty(const char *path, char *const argv[], char *const envp[],
} else if (childpid != 0) { /* parent */
ioctl(fdm, I_PUSH, "ptem");
- set_noecho(fdm);
+ if (console) {
+ set_noecho(fdm);
+ }
if (channels != NULL) {
/* close the write end of pipe1 */
- if (close(pipe2[1]) == -1)
+ if (console && close(pipe2[1]) == -1)
perror("close(pipe2[1])");
channels[0] = fdm; /* Input Stream. */
channels[1] = fdm; /* Output Stream. */
- channels[2] = pipe2[0]; /* stderr Stream. */
- //channels[2] = fdm; /* Input Stream. */
+ if (console) { /* stderr Stream. */
+ channels[2] = pipe2[0];
+ } else {
+ channels[2] = fdm;
+ }
}
free(full_path);
diff --git a/core/org.eclipse.cdt.core.solaris/library/exec_unix.c b/core/org.eclipse.cdt.core.solaris/library/exec_unix.c
index 207197bcb4..3098b9197d 100644
--- a/core/org.eclipse.cdt.core.solaris/library/exec_unix.c
+++ b/core/org.eclipse.cdt.core.solaris/library/exec_unix.c
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2002, 2006 QNX Software Systems and others.
+ * Copyright (c) 2002, 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
@@ -8,6 +8,7 @@
* Contributors:
* QNX Software Systems - initial API and implementation
* Wind River Systems, Inc.
+ * Mikhail Sennikovsky - bug 145737
*******************************************************************************/
#include "exec0.h"
#include <unistd.h>
@@ -19,7 +20,7 @@
#include <stdlib.h>
/* from pfind.c */
-extern char *pfind(const char *name);
+extern char *pfind(const char *name, char * const envp[]);
pid_t
exec0(const char *path, char *const argv[], char *const envp[],
@@ -33,7 +34,7 @@ exec0(const char *path, char *const argv[], char *const envp[],
* We use pfind() to check that the program exists and is an executable.
* If not pass the error up.
*/
- full_path = pfind(path);
+ full_path = pfind(path, envp);
if (full_path == NULL) {
fprintf(stderr, "Unable to find full path for \"%s\"\n", path);
return -1;
@@ -135,9 +136,18 @@ int wait0(pid_t pid)
int status;
int val = -1;
- if (pid < 0 || waitpid(pid, &status, 0) < 0)
+ if (pid < 0)
return -1;
-
+
+ for (;;) {
+ if (waitpid(pid, &status, 0) < 0) {
+ if (errno == EINTR) {
+ // interrupted system call - retry
+ continue;
+ }
+ }
+ break;
+ }
if (WIFEXITED(status)) {
val = WEXITSTATUS(status);
}
diff --git a/core/org.eclipse.cdt.core.solaris/library/openpty.c b/core/org.eclipse.cdt.core.solaris/library/openpty.c
index b21ed5d848..b1bf0895c0 100644
--- a/core/org.eclipse.cdt.core.solaris/library/openpty.c
+++ b/core/org.eclipse.cdt.core.solaris/library/openpty.c
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2002 - 2005 QNX Software Systems and others.
+ * Copyright (c) 2002, 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, Inc.
*******************************************************************************/
#include <sys/types.h>
#include <sys/stat.h>
@@ -28,7 +29,7 @@
*/
int ptym_open (char *pts_name);
-int ptys_open (int fdm, char * pts_name);
+int ptys_open (int fdm, const char * pts_name);
int
openpty(int *amaster, int *aslave, char *name, struct termios *termp, struct winsize *winp)
@@ -85,7 +86,7 @@ ptym_open(char * pts_name)
}
int
-ptys_open(int fdm, char * pts_name)
+ptys_open(int fdm, const char * pts_name)
{
int fds;
/* following should allocate controlling terminal */
diff --git a/core/org.eclipse.cdt.core.solaris/library/openpty.h b/core/org.eclipse.cdt.core.solaris/library/openpty.h
index a32845e84d..06b9fa758c 100644
--- a/core/org.eclipse.cdt.core.solaris/library/openpty.h
+++ b/core/org.eclipse.cdt.core.solaris/library/openpty.h
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2002 - 2005 QNX Software Systems and others.
+ * Copyright (c) 2002, 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,10 +7,11 @@
*
* Contributors:
* QNX Software Systems - initial API and implementation
+ * Wind River Systems, Inc.
*******************************************************************************/
#ifndef _OPENPTY_H
#define _OPENPTY_H
int ptym_open (char *pts_name);
-int ptys_open (int fdm, char * pts_name);
+int ptys_open (int fdm, const char * pts_name);
void set_noecho(int fd);
#endif
diff --git a/core/org.eclipse.cdt.core.solaris/library/pfind.c b/core/org.eclipse.cdt.core.solaris/library/pfind.c
index 2e278b2f68..635d66f519 100644
--- a/core/org.eclipse.cdt.core.solaris/library/pfind.c
+++ b/core/org.eclipse.cdt.core.solaris/library/pfind.c
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2002 - 2005 QNX Software Systems and others.
+ * Copyright (c) 2002, 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,9 @@
*
* Contributors:
* QNX Software Systems - initial API and implementation
+ * Wind River Systems, Inc.
+ * Mikhail Sennikovsky - bug 145737
+ * Everton Rufino Constantino (IBM) - bug 237611
*******************************************************************************/
/*
* pfind.c - Search for a binary in $PATH.
@@ -23,46 +26,67 @@
#endif
-char *pfind(const char *name)
+#define PATH_DEF "PATH="
+const int path_def_len = 5; /* strlen(PATH_DEF); */
+
+char * path_val(char * const envp[])
+{
+ int i;
+ if (envp == NULL || envp[0] == NULL)
+ return getenv("PATH" );
+
+ for(i = 0; envp[i] != NULL; i++){
+ char* p = envp[i];
+ if(!strncmp(PATH_DEF, p, path_def_len)){
+ return p + path_def_len;
+ }
+ }
+
+ return NULL;
+}
+
+char * pfind(const char *name, char * const envp[])
{
char *tok;
char *sp;
char *path;
char fullpath[PATH_MAX+1];
+ /* Sanity check. */
if (name == NULL) {
fprintf(stderr, "pfind(): Null argument.\n");
return NULL;
}
- /* For absolute namer or name with a path, check if it is an executable. */
+ /* For absolute name or name with a path, check if it is an executable. */
if (name[0] == '/' || name[0] == '.') {
- if (access(name, X_OK | R_OK) == 0) {
+ if (access(name, X_OK) == 0) {
return strdup(name);
}
return NULL;
}
/* Search in the PATH environment. */
- path = getenv("PATH");
+ path = path_val( envp );
+
if (path == NULL || strlen(path) <= 0) {
fprintf(stderr, "Unable to get $PATH.\n");
return NULL;
}
- // The value return by getenv() is readonly */
+ /* The value return by getenv() is readonly */
path = strdup(path);
tok = strtok_r(path, ":", &sp);
while (tok != NULL) {
snprintf(fullpath, sizeof(fullpath) - 1, "%s/%s", tok, name);
- if (access(fullpath, X_OK | R_OK) == 0) {
+ if (access(fullpath, X_OK) == 0) {
free(path);
return strdup(fullpath);
}
- tok = strtok_r(NULL, ":", &sp);
+ tok = strtok_r( NULL, ":", &sp );
}
free(path);
@@ -76,7 +100,7 @@ int main(int argc, char **argv)
char *fullpath;
for (i = 1; i<argc; i++) {
- fullpath = pfind(argv[i]);
+ fullpath = pfind(argv[i], NULL);
if (fullpath == NULL)
printf("Unable to find %s in $PATH.\n", argv[i]);
else
diff --git a/core/org.eclipse.cdt.core.solaris/library/pty.c b/core/org.eclipse.cdt.core.solaris/library/pty.c
index 37a7604457..a1d33b5396 100644
--- a/core/org.eclipse.cdt.core.solaris/library/pty.c
+++ b/core/org.eclipse.cdt.core.solaris/library/pty.c
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2002 - 2005 QNX Software Systems and others.
+ * Copyright (c) 2002, 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
@@ -17,7 +17,7 @@
* Signature: ()I
*/
JNIEXPORT jstring JNICALL
-Java_org_eclipse_cdt_utils_pty_PTY_openMaster (JNIEnv *env, jobject jobj) {
+Java_org_eclipse_cdt_utils_pty_PTY_openMaster (JNIEnv *env, jobject jobj, jboolean console) {
jfieldID fid; /* Store the field ID */
jstring jstr = NULL;
int master = -1;
@@ -28,8 +28,10 @@ Java_org_eclipse_cdt_utils_pty_PTY_openMaster (JNIEnv *env, jobject jobj) {
master = ptym_open(line);
if (master >= 0) {
- // turn off echo
- set_noecho(master);
+ if (console) {
+ // turn off echo
+ set_noecho(master);
+ }
/* Get a reference to the obj's class */
cls = (*env)->GetObjectClass(env, jobj);
@@ -46,3 +48,20 @@ Java_org_eclipse_cdt_utils_pty_PTY_openMaster (JNIEnv *env, jobject jobj) {
}
return jstr;
}
+
+JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_pty_PTY_change_1window_1size
+ (JNIEnv *env, jobject jobj, jint fdm, jint width, jint height)
+{
+#ifdef TIOCGWINSZ
+ struct winsize win;
+
+ win.ws_col = width;
+ win.ws_row = height;
+ win.ws_xpixel = 0;
+ win.ws_ypixel = 0;
+
+ return ioctl(fdm, TIOCSWINSZ, &win);
+#else
+ return 0;
+#endif
+}
diff --git a/core/org.eclipse.cdt.core.solaris/library/spawner.c b/core/org.eclipse.cdt.core.solaris/library/spawner.c
index b9215330f2..1d221516a5 100644
--- a/core/org.eclipse.cdt.core.solaris/library/spawner.c
+++ b/core/org.eclipse.cdt.core.solaris/library/spawner.c
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2002, 2006 QNX Software Systems and others.
+ * Copyright (c) 2002, 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
@@ -89,13 +89,13 @@ static void free_c_array(char **c_array)
*/
JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_exec2
(JNIEnv *env, jobject jobj, jobjectArray jcmd, jobjectArray jenv, jstring jdir, jintArray jchannels,
- jstring jslaveName, jint masterFD)
+ jstring jslaveName, jint masterFD, jboolean console)
{
jint *channels = (*env)->GetIntArrayElements(env, jchannels, 0);
const char *dirpath = (*env)->GetStringUTFChars(env, jdir, NULL);
const char *pts_name = (*env)->GetStringUTFChars(env, jslaveName, NULL);
- char **cmd;
- char **envp;
+ char **cmd = NULL;
+ char **envp = NULL;
int fd[3];
pid_t pid = -1;
@@ -119,7 +119,7 @@ JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_exec2
fprintf(stderr, "pts_name: %s\n", pts_name);
#endif
- pid = exec_pty(cmd[0], cmd, envp, dirpath, fd, pts_name, masterFD);
+ pid = exec_pty(cmd[0], cmd, envp, dirpath, fd, pts_name, masterFD, console);
if (pid < 0)
goto bail_out;
@@ -146,8 +146,8 @@ Java_org_eclipse_cdt_utils_spawner_Spawner_exec1(JNIEnv * env, jobject jobj,
jstring jdir)
{
const char *dirpath = (*env)->GetStringUTFChars(env, jdir, NULL);
- char **cmd;
- char **envp;
+ char **cmd = NULL;
+ char **envp = NULL;
pid_t pid = -1;
cmd = alloc_c_array(env, jcmd);
@@ -193,8 +193,8 @@ Java_org_eclipse_cdt_utils_spawner_Spawner_exec0(JNIEnv * env, jobject jobj,
{
jint *channels = (*env)->GetIntArrayElements(env, jchannels, 0);
const char *dirpath = (*env)->GetStringUTFChars(env, jdir, NULL);
- char **cmd;
- char **envp;
+ char **cmd = NULL;
+ char **envp = NULL;
int fd[3];
pid_t pid = -1;
diff --git a/core/org.eclipse.cdt.core.solaris/os/solaris/sparc/libpty.so b/core/org.eclipse.cdt.core.solaris/os/solaris/sparc/libpty.so
index 2333a6dd6a..7e5763d186 100644
--- a/core/org.eclipse.cdt.core.solaris/os/solaris/sparc/libpty.so
+++ b/core/org.eclipse.cdt.core.solaris/os/solaris/sparc/libpty.so
Binary files differ
diff --git a/core/org.eclipse.cdt.core.solaris/os/solaris/sparc/libspawner.so b/core/org.eclipse.cdt.core.solaris/os/solaris/sparc/libspawner.so
index 46c86d9f9e..bcee084b37 100644
--- a/core/org.eclipse.cdt.core.solaris/os/solaris/sparc/libspawner.so
+++ b/core/org.eclipse.cdt.core.solaris/os/solaris/sparc/libspawner.so
Binary files differ
diff --git a/core/org.eclipse.cdt.core.win32/META-INF/MANIFEST.MF b/core/org.eclipse.cdt.core.win32/META-INF/MANIFEST.MF
index 2d0c90221f..f0023d2a42 100644
--- a/core/org.eclipse.cdt.core.win32/META-INF/MANIFEST.MF
+++ b/core/org.eclipse.cdt.core.win32/META-INF/MANIFEST.MF
@@ -2,9 +2,10 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %fragmentName.win32
Bundle-SymbolicName: org.eclipse.cdt.core.win32; singleton:=true
-Bundle-Version: 5.1.0.qualifier
+Bundle-Version: 5.2.0.qualifier
Bundle-ClassPath: cdt_win32.jar
Bundle-Vendor: %providerName
-Fragment-Host: org.eclipse.cdt.core;bundle-version="[5.0.0,6.0.0)"
+Fragment-Host: org.eclipse.cdt.core;bundle-version="[5.2.0,6.0.0)"
Bundle-Localization: plugin
Bundle-RequiredExecutionEnvironment: J2SE-1.4
+Eclipse-PlatformFilter: (osgi.os=win32)
diff --git a/core/org.eclipse.cdt.core.win32/library/Spawner.h b/core/org.eclipse.cdt.core.win32/library/Spawner.h
index 6f5c9650e8..a78e7e45cc 100644
--- a/core/org.eclipse.cdt.core.win32/library/Spawner.h
+++ b/core/org.eclipse.cdt.core.win32/library/Spawner.h
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2002, 2007 QNX Software Systems and others.
+ * Copyright (c) 2002, 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
@@ -37,8 +37,13 @@ JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_exec0
JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_exec1
(JNIEnv *, jobject, jobjectArray, jobjectArray, jstring);
+/*
+ * Class: org_eclipse_cdt_utils_spawner_Spawner
+ * Method: exec2
+ * Signature: ([Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;LILjava/lang/String;IZ)I
+ */
JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_exec2
- (JNIEnv * env, jobject process, jobjectArray cmdarray, jobjectArray envp, jstring dir, jintArray channels, jstring slaveName, jint fdm);
+ (JNIEnv * env, jobject process, jobjectArray cmdarray, jobjectArray envp, jstring dir, jintArray channels, jstring slaveName, jint fdm, jboolean console);
/*
* Class: org_eclipse_cdt_utils_spawner_Spawner
diff --git a/core/org.eclipse.cdt.core.win32/library/Win32ProcessEx.c b/core/org.eclipse.cdt.core.win32/library/Win32ProcessEx.c
index 6339128cf1..097d7d2ee9 100644
--- a/core/org.eclipse.cdt.core.win32/library/Win32ProcessEx.c
+++ b/core/org.eclipse.cdt.core.win32/library/Win32ProcessEx.c
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2002, 2008 QNX Software Systems and others.
+ * Copyright (c) 2002, 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
@@ -100,7 +100,7 @@ static int nCounter = 0; // We use it to build unique synchronisation object nam
extern "C"
JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_exec2
- (JNIEnv * env, jobject process, jobjectArray cmdarray, jobjectArray envp, jstring dir, jintArray channels, jstring slaveName, jint fdm)
+ (JNIEnv * env, jobject process, jobjectArray cmdarray, jobjectArray envp, jstring dir, jintArray channels, jstring slaveName, jint fdm, jboolean console)
{
return -1;
}
diff --git a/core/org.eclipse.cdt.core.win32/os/win32/x86/spawner.dll b/core/org.eclipse.cdt.core.win32/os/win32/x86/spawner.dll
index faa495606a..f7a4d8d88d 100644
--- a/core/org.eclipse.cdt.core.win32/os/win32/x86/spawner.dll
+++ b/core/org.eclipse.cdt.core.win32/os/win32/x86/spawner.dll
Binary files differ
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CCorePluginResources.properties b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CCorePluginResources.properties
index b1f5fe462e..928e98920b 100644
--- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CCorePluginResources.properties
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CCorePluginResources.properties
@@ -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
@@ -62,6 +62,7 @@ Util.exception.missingBytes=missing bytes
Util.exception.noData=no more data
Util.exception.cannotCreatePty=Cannot create pty
Util.exception.closeError=close error
+Util.exception.cannotSetTerminalSize=Setting terminal size is not supported
Util.error.cannotRun=Cannot run program "{0}": {1}
Util.unknownName=unknown C++ encoded name
Util.unknownFormat=Unknown debug format
diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/pty/PTY.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/pty/PTY.java
index 41fc6a9b54..137955125d 100644
--- a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/pty/PTY.java
+++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/pty/PTY.java
@@ -1,12 +1,13 @@
/*******************************************************************************
- * Copyright (c) 2002, 2006 QNX Software Systems and others.
+ * Copyright (c) 2002, 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
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * QNX Software Systems - Initial API and implementation
+ * QNX Software Systems - Initial API and implementation
+ * Wind River Systems, Inc. - bug 248071
*******************************************************************************/
package org.eclipse.cdt.utils.pty;
@@ -15,24 +16,25 @@ import java.io.IOException;
import org.eclipse.cdt.core.CCorePlugin;
/**
- * PTY
- * pseudo terminal code.
+ * PTY - pseudo terminal support.
*/
public class PTY {
+ final boolean console;
String slave;
PTYInputStream in;
PTYOutputStream out;
/**
- * NOTE: Field access by the native layer do not refactor.
+ * NOTE: Field is accessed by the native layer. Do not refactor!
*/
int master;
private static boolean hasPTY;
+ private static boolean setTerminalSizeErrorAlreadyLogged;
/**
- * 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.
+ * The master fd is used on two streams. We need to wrap the fd
+ * so that when stream.close() is called the other stream is disabled.
*/
public class MasterFD {
@@ -45,9 +47,41 @@ public class PTY {
}
}
+ /**
+ * Create PTY for use with Eclipse console.
+ * Identical to {@link PTY#PTY(boolean) PTY(true)}.
+ */
public PTY() throws IOException {
+ this(true);
+ }
+
+ /**
+ * Create pseudo terminal.
+ *
+ * <p>
+ * The provided flag indicates whether the pseudo terminal is used with the interactive
+ * Eclipse console:
+ * <ul>
+ * <li>If <code>true</code> the terminal is configured with no echo and stderr is
+ * redirected to a pipe instead of the PTY.</li>
+ * <li>If <code>false</code> the terminal is configured with echo and stderr is
+ * connected to the PTY. This mode is best suited for use with a proper terminal emulation.
+ * Note that this mode might not be supported on all platforms.
+ * Known platforms which support this mode are:
+ * <code>linux-x86</code>, <code>linux-x86_64</code>, <code>solaris-sparc</code>, <code>macosx</code>.
+ * </li>
+ * </ul>
+ * </p>
+ *
+ * @param console whether terminal is used with Eclipse console
+ * @throws IOException if the PTY could not be created
+ * @since 5.2
+ */
+ public PTY(boolean console) throws IOException {
+ this.console = console;
+
if (hasPTY) {
- slave= openMaster();
+ slave= openMaster(console);
}
if (slave == null) {
@@ -66,6 +100,15 @@ public class PTY {
return new MasterFD();
}
+ /**
+ * @return whether this pseudo terminal is for use with the Eclipse console.
+ *
+ * @since 5.2
+ */
+ public final boolean isConsole() {
+ return console;
+ }
+
public PTYOutputStream getOutputStream() {
return out;
}
@@ -74,11 +117,42 @@ public class PTY {
return in;
}
+ /**
+ * Change terminal window size to given width and height.
+ * <p>
+ * This should only be used when the pseudo terminal is configured
+ * for use with a terminal emulation, i.e. when {@link #isConsole()}
+ * returns <code>false</code>.
+ * </p>
+ * <p>
+ * <strong>Note:</strong> This method may not be supported on all platforms.
+ * Known platforms which support this method are:
+ * <code>linux-x86</code>, <code>linux-x86_64</code>, <code>solaris-sparc</code>, <code>macosx</code>.
+ * </p>
+ *
+ * @since 5.2
+ */
+ public final void setTerminalSize(int width, int height) {
+ try {
+ change_window_size(master, width, height);
+ } catch (UnsatisfiedLinkError ule) {
+ if (!setTerminalSizeErrorAlreadyLogged) {
+ setTerminalSizeErrorAlreadyLogged = true;
+ CCorePlugin.log(CCorePlugin.getResourceString("Util.exception.cannotSetTerminalSize"), ule); //$NON-NLS-1$
+ }
+ }
+ }
+
+ /**
+ * @return whether PTY support is available on this platform
+ */
public static boolean isSupported() {
return hasPTY;
}
- native String openMaster();
+ native String openMaster(boolean console);
+
+ native int change_window_size(int fdm, int width, int height);
static {
try {
diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/spawner/Spawner.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/spawner/Spawner.java
index a8e40c6408..aad306f08c 100644
--- a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/spawner/Spawner.java
+++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/spawner/Spawner.java
@@ -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,7 +7,7 @@
*
* Contributors:
* QNX Software Systems - Initial API and implementation
- * Anton Leherbauer (Wind River Systems)
+ * Wind River Systems, Inc. - bug 248071
*******************************************************************************/
package org.eclipse.cdt.utils.spawner;
@@ -262,6 +262,7 @@ public class Spawner extends Process {
final String slaveName = pty.getSlaveName();
final int masterFD = pty.getMasterFD().getFD();
+ final boolean console = pty.isConsole();
//int fdm = pty.get
Reaper reaper = new Reaper(cmdarray, envp, dirpath) {
/* (non-Javadoc)
@@ -269,7 +270,7 @@ public class Spawner extends Process {
*/
@Override
int execute(String[] cmd, String[] env, String dir, int[] channels) throws IOException {
- return exec2(cmd, env, dir, channels, slaveName, masterFD);
+ return exec2(cmd, env, dir, channels, slaveName, masterFD, console);
}
};
reaper.setDaemon(true);
@@ -318,7 +319,7 @@ public class Spawner extends Process {
/**
* Native method when executing with a terminal emulation.
*/
- native int exec2( String[] cmdarray, String[] envp, String dir, int[] chan, String slaveName, int masterFD) throws IOException;
+ native int exec2( String[] cmdarray, String[] envp, String dir, int[] chan, String slaveName, int masterFD, boolean console) throws IOException;
/**
* Native method to drop a signal on the process with pid.

Back to the top