Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'core/org.eclipse.cdt.core.qnx')
-rw-r--r--core/org.eclipse.cdt.core.qnx/library/pty/PTY.h7
-rw-r--r--core/org.eclipse.cdt.core.qnx/library/pty/pty.c2
-rw-r--r--core/org.eclipse.cdt.core.qnx/library/spawner/Spawner.h20
-rw-r--r--core/org.eclipse.cdt.core.qnx/library/spawner/spawner.c123
-rw-r--r--core/org.eclipse.cdt.core.qnx/os/qnx/x86/libpty.sobin7028 -> 5412 bytes
-rw-r--r--core/org.eclipse.cdt.core.qnx/os/qnx/x86/libspawner.sobin9426 -> 9840 bytes
6 files changed, 141 insertions, 11 deletions
diff --git a/core/org.eclipse.cdt.core.qnx/library/pty/PTY.h b/core/org.eclipse.cdt.core.qnx/library/pty/PTY.h
index fabf58152d0..46a8dd9b622 100644
--- a/core/org.eclipse.cdt.core.qnx/library/pty/PTY.h
+++ b/core/org.eclipse.cdt.core.qnx/library/pty/PTY.h
@@ -7,12 +7,13 @@
#ifdef __cplusplus
extern "C" {
#endif
+/* Inaccessible static: hasPTY */
/*
* Class: org_eclipse_cdt_utils_pty_PTY
- * Method: forkpty
- * Signature: ()I
+ * Method: openMaster
+ * Signature: ()Ljava/lang/String;
*/
-JNIEXPORT jstring JNICALL Java_org_eclipse_cdt_utils_pty_PTY_forkpty
+JNIEXPORT jstring JNICALL Java_org_eclipse_cdt_utils_pty_PTY_openMaster
(JNIEnv *, jobject);
#ifdef __cplusplus
diff --git a/core/org.eclipse.cdt.core.qnx/library/pty/pty.c b/core/org.eclipse.cdt.core.qnx/library/pty/pty.c
index 4b9e682c3ee..1ff87e17c7f 100644
--- a/core/org.eclipse.cdt.core.qnx/library/pty/pty.c
+++ b/core/org.eclipse.cdt.core.qnx/library/pty/pty.c
@@ -7,7 +7,7 @@
* Signature: ()I
*/
JNIEXPORT jstring JNICALL
-Java_org_eclipse_cdt_utils_pty_PTY_forkpty (JNIEnv *env, jobject jobj) {
+Java_org_eclipse_cdt_utils_pty_PTY_openMaster (JNIEnv *env, jobject jobj) {
jfieldID fid; /* Store the field ID */
jstring jstr = NULL;
int master = -1;
diff --git a/core/org.eclipse.cdt.core.qnx/library/spawner/Spawner.h b/core/org.eclipse.cdt.core.qnx/library/spawner/Spawner.h
index 287c8370ab0..272366bad75 100644
--- a/core/org.eclipse.cdt.core.qnx/library/spawner/Spawner.h
+++ b/core/org.eclipse.cdt.core.qnx/library/spawner/Spawner.h
@@ -1,9 +1,9 @@
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
-/* Header for class com_qnx_tools_utils_spawner_Spawner */
+/* Header for class org_eclipse_cdt_utils_spawner_Spawner */
-#ifndef _Included_com_qnx_tools_utils_spawner_Spawner
-#define _Included_com_qnx_tools_utils_spawner_Spawner
+#ifndef _Included_org_eclipse_cdt_utils_spawner_Spawner
+#define _Included_org_eclipse_cdt_utils_spawner_Spawner
#ifdef __cplusplus
extern "C" {
#endif
@@ -17,12 +17,20 @@ JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_exec0
/*
* Class: org_eclipse_cdt_utils_spawner_Spawner
- * Method: exec0
- * Signature: ([Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;[I)I
+ * Method: exec1
+ * Signature: ([Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;)I
*/
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;[ILjava/lang/String;I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_exec2
+ (JNIEnv *, jobject, jobjectArray, jobjectArray, jstring, jintArray, jstring, jint);
+
/*
* Class: org_eclipse_cdt_utils_spawner_Spawner
* Method: raise
diff --git a/core/org.eclipse.cdt.core.qnx/library/spawner/spawner.c b/core/org.eclipse.cdt.core.qnx/library/spawner/spawner.c
index a6c1cef581f..c6d638f7ab1 100644
--- a/core/org.eclipse.cdt.core.qnx/library/spawner/spawner.c
+++ b/core/org.eclipse.cdt.core.qnx/library/spawner/spawner.c
@@ -205,6 +205,127 @@ JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_exec1
}
+JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_exec2
+ (JNIEnv * env, jobject proc, jobjectArray cmdArray, jobjectArray envp, jstring dir, jintArray channels, jstring jslave, jint master)
+{
+ int fd_map[3]; /* File descriptors. */
+ int fd_ret[3]; /* File descriptors that we return to Java. */
+ int fd[2]; /* Pipe open structure. */
+ int i;
+ int nParms = 0;/* Number of parameters. */
+ int nEnvs = 0;/* Number of environment variables. */
+ char ** pParms = NULL; /* Parameters. */
+ char ** pEnvs = NULL; /* Environment variables. */
+ char * pCommand = NULL; /* Command to execute. */
+ char cwd[PATH_MAX + 1]; /* Current working directory. */
+ pid_t pid; /* Process ID. */
+ struct inheritance inherit;
+
+ if ((cmdArray == NULL) || ((nParms = (*env)->GetArrayLength(env, cmdArray)) == 0)) {
+ ThrowByName(env, "java/lang/IOException", "No command line specified");
+ }
+
+ {
+ char *pts_name = (char *)(*env)->GetStringUTFChars(env, jslave, 0);
+ int fds = ptys_open(master, pts_name);
+ (*env)->ReleaseStringUTFChars(env, jslave, pts_name);
+ if (fds == -1) {
+ ThrowByName(env, "java/io/IOException", "Cannot create pipe for spawner");
+ }
+ if (EOK != pipe(fd)) {
+ ThrowByName(env, "java/io/IOException", "Cannot create pipe for spawner");
+ }
+ fd_map[0] = fd_map[1] = fds;
+ fd_map[2] = fd[1];
+ fd_ret[0] = fd_ret[1] = master;
+ fd_ret[3] = fd[0];
+ }
+
+ if (nParms > 0) {
+ pParms = malloc(sizeof(char *) * (nParms + 1));
+ for (i = 0; i < nParms; ++i) {
+ jobject item = (*env)->GetObjectArrayElement(env, cmdArray, i);
+ const char *str = (*env)->GetStringUTFChars(env, item, 0);
+ if (i == 0)
+ pCommand = strdup(str);
+ pParms[i] = strdup(str);
+ (*env)->ReleaseStringUTFChars(env, item, str);
+ }
+ pParms[i] = NULL;
+ }
+
+ nEnvs = (*env) -> GetArrayLength(env, envp);
+ if (nEnvs > 0) {
+ pEnvs = malloc(sizeof(char *) * (nEnvs + 1));
+ for (i = 0; i < nEnvs; ++i) {
+ jobject item = (*env)->GetObjectArrayElement(env, envp, i);
+ const char *str = (*env)->GetStringUTFChars(env, item, 0);
+ pEnvs[i] = strdup(str);
+ (*env)->ReleaseStringUTFChars(env, item, str);
+ }
+ pEnvs[i] = NULL;
+ }
+
+ if (dir != 0) {
+ char *item = (char *)(*env)->GetStringUTFChars(env, dir, 0);
+ getcwd(cwd, sizeof(cwd));
+ chdir(item);
+ (*env)->ReleaseStringUTFChars(env, dir, item);
+ }
+
+ /* Nothing for now. */
+ memset(&inherit, 0, sizeof(inherit));
+ inherit.flags = SPAWN_SETGROUP;
+ inherit.pgroup = SPAWN_NEWPGROUP;
+
+ pid = spawnp(pCommand, 3, fd_map, &inherit, pParms, pEnvs);
+
+ if (dir != 0) /* Restore working directory. */
+ chdir(cwd);
+
+ for (i = 0; i < 3; ++i) {
+ close(fd_map[i]);
+ }
+
+ if (-1 == pid) { /* Failed - close pipes. */
+ for (i = 0; i < 3; ++i) {
+ close(fd_ret[i]);
+ }
+ } else { /* Success - return pipes to Java. */
+ (*env) -> SetIntArrayRegion(env, channels, 0, 3, fd_ret);
+ }
+
+ /* Free Parameters. */
+ if (pParms != NULL) {
+ int j;
+ for (j = 0; pParms[j] != NULL; j++) {
+ if (pParms[j] != NULL) {
+ free(pParms[j]);
+ }
+ }
+ free(pParms);
+ }
+
+ /* Free Environment variables. */
+ if (pEnvs != NULL) {
+ int j;
+ for (j = 0; pEnvs[j] != NULL; j++) {
+ if (pEnvs[j] != NULL) {
+ free(pEnvs[j]);
+ }
+ }
+ free(pEnvs);
+ }
+
+ /* Free Command to execute. */
+ if (pCommand != NULL) {
+ free(pCommand);
+ }
+
+ return pid;
+
+}
+
/*
* Class: com_qnx_tools_utils_spawner_Spawner
* Method: raise
@@ -224,7 +345,7 @@ JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_raise
JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_waitFor
(JNIEnv * env, jobject proc, jint pid)
{
- int ret;
+ int ret, stat_loc;
int val = -1;
ret = waitpid(pid, &stat_loc, WEXITED);
diff --git a/core/org.eclipse.cdt.core.qnx/os/qnx/x86/libpty.so b/core/org.eclipse.cdt.core.qnx/os/qnx/x86/libpty.so
index 6af6b21e775..7e8be555ff2 100644
--- a/core/org.eclipse.cdt.core.qnx/os/qnx/x86/libpty.so
+++ b/core/org.eclipse.cdt.core.qnx/os/qnx/x86/libpty.so
Binary files differ
diff --git a/core/org.eclipse.cdt.core.qnx/os/qnx/x86/libspawner.so b/core/org.eclipse.cdt.core.qnx/os/qnx/x86/libspawner.so
index 8744bb15a6c..61f6c9d9ef6 100644
--- a/core/org.eclipse.cdt.core.qnx/os/qnx/x86/libspawner.so
+++ b/core/org.eclipse.cdt.core.qnx/os/qnx/x86/libspawner.so
Binary files differ

Back to the top