mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-01 06:05:24 +02:00
Initial contribution of AIX port.
This commit is contained in:
parent
58d60e53f4
commit
63b3ca67db
25 changed files with 1221 additions and 0 deletions
16
core/org.eclipse.cdt.core.aix/.classpath
Normal file
16
core/org.eclipse.cdt.core.aix/.classpath
Normal file
|
@ -0,0 +1,16 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src/"/>
|
||||
<classpathentry kind="src" path="/org.eclipse.cdt.core"/>
|
||||
<classpathentry kind="src" path="/org.eclipse.core.resources"/>
|
||||
<classpathentry kind="src" path="/org.eclipse.core.runtime"/>
|
||||
<classpathentry kind="src" path="/org.apache.xerces"/>
|
||||
<classpathentry kind="src" path="/org.eclipse.search"/>
|
||||
<classpathentry kind="src" path="/org.eclipse.compare"/>
|
||||
<classpathentry kind="src" path="/org.eclipse.debug.core"/>
|
||||
<classpathentry kind="src" path="/org.eclipse.team.core"/>
|
||||
<classpathentry kind="src" path="/org.eclipse.ui"/>
|
||||
<classpathentry kind="src" path="/org.eclipse.core.boot"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
38
core/org.eclipse.cdt.core.aix/.project
Normal file
38
core/org.eclipse.cdt.core.aix/.project
Normal file
|
@ -0,0 +1,38 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>org.eclipse.cdt.core.aix</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
<project>org.apache.xerces</project>
|
||||
<project>org.eclipse.cdt.core</project>
|
||||
<project>org.eclipse.compare</project>
|
||||
<project>org.eclipse.core.boot</project>
|
||||
<project>org.eclipse.core.resources</project>
|
||||
<project>org.eclipse.core.runtime</project>
|
||||
<project>org.eclipse.debug.core</project>
|
||||
<project>org.eclipse.search</project>
|
||||
<project>org.eclipse.team.core</project>
|
||||
<project>org.eclipse.ui</project>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.ManifestBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.SchemaBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.pde.PluginNature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
4
core/org.eclipse.cdt.core.aix/.template
Normal file
4
core/org.eclipse.cdt.core.aix/.template
Normal file
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form>
|
||||
<p/><p><b>Tips on working with this plug-in project</b></p><li>For the view of the new plug-in at a glance, go to the <img href="pageImage"/><a href="OverviewPage">Overview</a>.</li><li>You can test the contributions of this plug-in by launching another instance of the workbench. On the <b>Run</b> menu, click <b>Run As</b> and choose <img href="runTimeWorkbenchImage"/><a href="action.run">Run-time Workbench</a> from the available choices.</li><li>You can add more functionality to this plug-in by adding extensions using the <a href="action.newExtension">New Extension Wizard</a>.</li><li>The plug-in project contains Java code that you can debug. Place breakpoints in Java classes. On the <b>Run</b> menu, select <b>Debug As</b> and choose <img href="runTimeWorkbenchImage"/><a href="action.debug">Run-time Workbench</a> from the available choices.</li>
|
||||
</form>
|
4
core/org.eclipse.cdt.core.aix/build.properties
Normal file
4
core/org.eclipse.cdt.core.aix/build.properties
Normal file
|
@ -0,0 +1,4 @@
|
|||
source.cdtaix.jar = src/
|
||||
bin.includes = fragment.xml,\
|
||||
*.jar,\
|
||||
cdtaix.jar
|
2
core/org.eclipse.cdt.core.aix/fragment.properties
Normal file
2
core/org.eclipse.cdt.core.aix/fragment.properties
Normal file
|
@ -0,0 +1,2 @@
|
|||
fragmentName=C/C++ Development Tools Core AIX Fragment
|
||||
providerName=Eclipse.org
|
20
core/org.eclipse.cdt.core.aix/fragment.xml
Normal file
20
core/org.eclipse.cdt.core.aix/fragment.xml
Normal file
|
@ -0,0 +1,20 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<fragment
|
||||
id="org.eclipse.cdt.core.aix"
|
||||
name="%fragmentName"
|
||||
version="1.1.0"
|
||||
provider-name="%providerName"
|
||||
plugin-id="org.eclipse.cdt.core"
|
||||
plugin-version="1.1.0">
|
||||
|
||||
<runtime>
|
||||
<library name="cdtaix.jar"/>
|
||||
</runtime>
|
||||
|
||||
<requires>
|
||||
<import plugin="org.eclipse.core.resources"/>
|
||||
<import plugin="org.eclipse.ui"/>
|
||||
</requires>
|
||||
|
||||
|
||||
</fragment>
|
1
core/org.eclipse.cdt.core.aix/library/.cvsignore
Normal file
1
core/org.eclipse.cdt.core.aix/library/.cvsignore
Normal file
|
@ -0,0 +1 @@
|
|||
*.o
|
29
core/org.eclipse.cdt.core.aix/library/Makefile
Normal file
29
core/org.eclipse.cdt.core.aix/library/Makefile
Normal file
|
@ -0,0 +1,29 @@
|
|||
# makefile for libspawner.so
|
||||
|
||||
#set JDK_INCLUDES
|
||||
JDK_INCLUDES=/usr/java131/include
|
||||
|
||||
CC=xlc
|
||||
CFLAGS = -I. -I$(JDK_INCLUDES)
|
||||
#CFLAGS +=-fpic -D_REENTRANT
|
||||
|
||||
LIB_NAME_SPAWNER = libspawner.so
|
||||
LIB_NAME_FULL_SPAWNER = ../os/aix/ppc/libspawner.so
|
||||
OBJS_SPAWNER=spawner.o io.o exec_unix.o pfind.o
|
||||
|
||||
LIB_NAME_PTY = libpty.so
|
||||
LIB_NAME_FULL_PTY = ../os/aix/ppc/libpty.so
|
||||
OBJS_PTY=openpty.o pty.o ptyio.o
|
||||
|
||||
all: $(LIB_NAME_FULL_SPAWNER) $(LIB_NAME_FULL_PTY)
|
||||
|
||||
$(LIB_NAME_FULL_SPAWNER): $(OBJS_SPAWNER)
|
||||
mkdir -p ../os/aix/ppc
|
||||
$(CC) -G -o $(LIB_NAME_FULL_SPAWNER) $(OBJS_SPAWNER) -lc
|
||||
|
||||
$(LIB_NAME_FULL_PTY): $(OBJS_PTY)
|
||||
$(CC) -G -o $(LIB_NAME_FULL_PTY) $(OBJS_PTY)
|
||||
|
||||
clean :
|
||||
$(RM) $(OBJS_SPAWNER) $(LIB_NAME_FULL_SPAWNER)
|
||||
$(RM) $(OBJS_PTY) $(LIB_NAME_FULL_PTY)
|
21
core/org.eclipse.cdt.core.aix/library/PTY.h
Normal file
21
core/org.eclipse.cdt.core.aix/library/PTY.h
Normal file
|
@ -0,0 +1,21 @@
|
|||
/* DO NOT EDIT THIS FILE - it is machine generated */
|
||||
#include <jni.h>
|
||||
/* Header for class org_eclipse_cdt_utils_pty_PTY */
|
||||
|
||||
#ifndef _Included_org_eclipse_cdt_utils_pty_PTY
|
||||
#define _Included_org_eclipse_cdt_utils_pty_PTY
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
/*
|
||||
* Class: org_eclipse_cdt_utils_pty_PTY
|
||||
* Method: forkpty
|
||||
* Signature: ()I
|
||||
*/
|
||||
JNIEXPORT jstring JNICALL Java_org_eclipse_cdt_utils_pty_PTY_forkpty
|
||||
(JNIEnv *, jobject);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
32
core/org.eclipse.cdt.core.aix/library/PTYInputStream.h
Normal file
32
core/org.eclipse.cdt.core.aix/library/PTYInputStream.h
Normal file
|
@ -0,0 +1,32 @@
|
|||
/* DO NOT EDIT THIS FILE - it is machine generated */
|
||||
#include <jni.h>
|
||||
/* Header for class org_eclipse_cdt_utils_pty_PTYInputStream */
|
||||
|
||||
#ifndef _Included_org_eclipse_cdt_utils_pty_PTYInputStream
|
||||
#define _Included_org_eclipse_cdt_utils_pty_PTYInputStream
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#undef org_eclipse_cdt_utils_pty_PTYInputStream_SKIP_BUFFER_SIZE
|
||||
#define org_eclipse_cdt_utils_pty_PTYInputStream_SKIP_BUFFER_SIZE 2048L
|
||||
/* Inaccessible static: skipBuffer */
|
||||
/*
|
||||
* Class: org_eclipse_cdt_utils_pty_PTYInputStream
|
||||
* Method: read0
|
||||
* Signature: (I[BI)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_pty_PTYInputStream_read0
|
||||
(JNIEnv *, jobject, jint, jbyteArray, jint);
|
||||
|
||||
/*
|
||||
* Class: org_eclipse_cdt_utils_pty_PTYInputStream
|
||||
* Method: close0
|
||||
* Signature: (I)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_pty_PTYInputStream_close0
|
||||
(JNIEnv *, jobject, jint);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
29
core/org.eclipse.cdt.core.aix/library/PTYOutputStream.h
Normal file
29
core/org.eclipse.cdt.core.aix/library/PTYOutputStream.h
Normal file
|
@ -0,0 +1,29 @@
|
|||
/* DO NOT EDIT THIS FILE - it is machine generated */
|
||||
#include <jni.h>
|
||||
/* Header for class org_eclipse_cdt_utils_pty_PTYOutputStream */
|
||||
|
||||
#ifndef _Included_org_eclipse_cdt_utils_pty_PTYOutputStream
|
||||
#define _Included_org_eclipse_cdt_utils_pty_PTYOutputStream
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
/*
|
||||
* Class: org_eclipse_cdt_utils_pty_PTYOutputStream
|
||||
* Method: write0
|
||||
* Signature: (I[BI)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_pty_PTYOutputStream_write0
|
||||
(JNIEnv *, jobject, jint, jbyteArray, jint);
|
||||
|
||||
/*
|
||||
* Class: org_eclipse_cdt_utils_pty_PTYOutputStream
|
||||
* Method: close0
|
||||
* Signature: (I)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_pty_PTYOutputStream_close0
|
||||
(JNIEnv *, jobject, jint);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
45
core/org.eclipse.cdt.core.aix/library/Spawner.h
Normal file
45
core/org.eclipse.cdt.core.aix/library/Spawner.h
Normal file
|
@ -0,0 +1,45 @@
|
|||
/* DO NOT EDIT THIS FILE - it is machine generated */
|
||||
#include <jni.h>
|
||||
/* Header for class com_qnx_tools_utils_spawner_Spawner */
|
||||
|
||||
#ifndef _Included_com_qnx_tools_utils_spawner_Spawner
|
||||
#define _Included_com_qnx_tools_utils_spawner_Spawner
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
/*
|
||||
* Class: org_eclipse_cdt_utils_spawner_Spawner
|
||||
* Method: exec0
|
||||
* Signature: ([Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;[I)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_exec0
|
||||
(JNIEnv *, jobject, jobjectArray, jobjectArray, jstring, jintArray);
|
||||
|
||||
/*
|
||||
* Class: org_eclipse_cdt_utils_spawner_Spawner
|
||||
* Method: exec0
|
||||
* Signature: ([Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;[I)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: raise
|
||||
* Signature: (II)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_raise
|
||||
(JNIEnv *, jobject, jint, jint);
|
||||
|
||||
/*
|
||||
* Class: org_eclipse_cdt_utils_spawner_Spawner
|
||||
* Method: waitFor
|
||||
* Signature: (I)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_waitFor
|
||||
(JNIEnv *, jobject, jint);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
32
core/org.eclipse.cdt.core.aix/library/SpawnerInputStream.h
Normal file
32
core/org.eclipse.cdt.core.aix/library/SpawnerInputStream.h
Normal file
|
@ -0,0 +1,32 @@
|
|||
/* DO NOT EDIT THIS FILE - it is machine generated */
|
||||
#include <jni.h>
|
||||
/* Header for class com_qnx_tools_utils_spawner_SpawnerInputStream */
|
||||
|
||||
#ifndef _Included_com_qnx_tools_utils_spawner_SpawnerInputStream
|
||||
#define _Included_com_qnx_tools_utils_spawner_SpawnerInputStream
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#undef com_qnx_tools_utils_spawner_SpawnerInputStream_SKIP_BUFFER_SIZE
|
||||
#define com_qnx_tools_utils_spawner_SpawnerInputStream_SKIP_BUFFER_SIZE 2048L
|
||||
/* Inaccessible static: skipBuffer */
|
||||
/*
|
||||
* Class: org_elipse_cdt_utils_spawner_SpawnerInputStream
|
||||
* Method: read0
|
||||
* Signature: (I[BI)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_SpawnerInputStream_read0
|
||||
(JNIEnv *, jobject, jint, jbyteArray, jint);
|
||||
|
||||
/*
|
||||
* Class: org_eclipse_cdt_utils_spawner_SpawnerInputStream
|
||||
* Method: close0
|
||||
* Signature: (I)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_SpawnerInputStream_close0
|
||||
(JNIEnv *, jobject, jint);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
29
core/org.eclipse.cdt.core.aix/library/SpawnerOutputStream.h
Normal file
29
core/org.eclipse.cdt.core.aix/library/SpawnerOutputStream.h
Normal file
|
@ -0,0 +1,29 @@
|
|||
/* DO NOT EDIT THIS FILE - it is machine generated */
|
||||
#include <jni.h>
|
||||
/* Header for class com_qnx_tools_utils_spawner_SpawnerOutputStream */
|
||||
|
||||
#ifndef _Included_com_qnx_tools_utils_spawner_SpawnerOutputStream
|
||||
#define _Included_com_qnx_tools_utils_spawner_SpawnerOutputStream
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
/*
|
||||
* Class: org_eclipse_cdt_utils_spawner_SpawnerOutputStream
|
||||
* Method: write0
|
||||
* Signature: (I[BI)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_SpawnerOutputStream_write0
|
||||
(JNIEnv *, jobject, jint, jbyteArray, jint);
|
||||
|
||||
/*
|
||||
* Class: org_eclipse_cdt_utils_spawner_SpawnerOutputStream
|
||||
* Method: close0
|
||||
* Signature: (I)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_SpawnerOutputStream_close0
|
||||
(JNIEnv *, jobject, jint);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
11
core/org.eclipse.cdt.core.aix/library/exec0.h
Normal file
11
core/org.eclipse.cdt.core.aix/library/exec0.h
Normal file
|
@ -0,0 +1,11 @@
|
|||
#include <unistd.h>
|
||||
#include <sys/wait.h>
|
||||
#include <sys/types.h>
|
||||
#include <signal.h>
|
||||
#include <errno.h>
|
||||
|
||||
extern pid_t exec0(const char *path, char *const argv[],
|
||||
char *const envp[], const char *dirpath,
|
||||
int channels[3] );
|
||||
|
||||
extern int wait0(pid_t pid);
|
135
core/org.eclipse.cdt.core.aix/library/exec_unix.c
Normal file
135
core/org.eclipse.cdt.core.aix/library/exec_unix.c
Normal file
|
@ -0,0 +1,135 @@
|
|||
#include "exec0.h"
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <libgen.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/* from pfind.c */
|
||||
extern char *pfind(const char *name);
|
||||
|
||||
pid_t
|
||||
exec0(const char *path, char *const argv[], char *const envp[],
|
||||
const char *dirpath, int channels[3])
|
||||
{
|
||||
int pipe0[2], pipe1[2], pipe2[2];
|
||||
pid_t childpid;
|
||||
char *full_path;
|
||||
|
||||
/*
|
||||
* 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);
|
||||
if (full_path == NULL) {
|
||||
fprintf(stderr, "Unable to find full path for \"%s\"\n", (path) ? path : "");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Make sure we can create our pipes before forking.
|
||||
*/
|
||||
if (channels != NULL) {
|
||||
if (pipe(pipe0) < 0 || pipe(pipe1) < 0 || pipe(pipe2) < 0) {
|
||||
fprintf(stderr, "%s(%d): returning due to error.\n",
|
||||
__FUNCTION__, __LINE__);
|
||||
free(full_path);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
childpid = fork();
|
||||
|
||||
if (childpid < 0) {
|
||||
fprintf(stderr, "%s(%d): returning due to error: %s\n",
|
||||
__FUNCTION__, __LINE__, strerror(errno));
|
||||
free(full_path);
|
||||
return -1;
|
||||
} else if (childpid == 0) { /* child */
|
||||
char *ptr;
|
||||
|
||||
chdir(dirpath);
|
||||
|
||||
if (channels != NULL) {
|
||||
/* Close the write end of pipe0 */
|
||||
if (close(pipe0[1]) == -1)
|
||||
perror("close(pipe0[1])");
|
||||
|
||||
/* Close the read end of pipe1 */
|
||||
if (close(pipe1[0]) == -1)
|
||||
perror("close(pipe1[0])");
|
||||
|
||||
/* Close the read end of pipe2 */
|
||||
if (close(pipe2[0]) == -1)
|
||||
perror("close(pipe2[0]))");
|
||||
|
||||
/* redirections */
|
||||
dup2(pipe0[0], STDIN_FILENO); /* dup stdin */
|
||||
dup2(pipe1[1], STDOUT_FILENO); /* dup stdout */
|
||||
dup2(pipe2[1], STDERR_FILENO); /* dup stderr */
|
||||
}
|
||||
|
||||
/* Close all the fd's in the child */
|
||||
{
|
||||
int fdlimit = sysconf(_SC_OPEN_MAX);
|
||||
int fd = 3;
|
||||
|
||||
while (fd < fdlimit)
|
||||
close(fd++);
|
||||
}
|
||||
|
||||
if (envp[0] == NULL) {
|
||||
execv(full_path, argv);
|
||||
} else {
|
||||
execve(full_path, argv, envp);
|
||||
}
|
||||
|
||||
_exit(127);
|
||||
|
||||
} else if (childpid != 0) { /* parent */
|
||||
|
||||
char b;
|
||||
|
||||
if (channels != NULL) {
|
||||
/* close the read end of pipe1 */
|
||||
if (close(pipe0[0]) == -1)
|
||||
perror("close(pipe0[0])");
|
||||
|
||||
/* close the write end of pipe2 */
|
||||
if (close(pipe1[1]) == -1)
|
||||
perror("close(pipe1[1])");
|
||||
|
||||
/* close the write end of pipe2 */
|
||||
if (close(pipe2[1]) == -1)
|
||||
perror("close(pipe2[1])");
|
||||
|
||||
channels[0] = pipe0[1]; /* Output Stream. */
|
||||
channels[1] = pipe1[0]; /* Input Stream. */
|
||||
channels[2] = pipe2[0]; /* Input Stream. */
|
||||
}
|
||||
|
||||
free(full_path);
|
||||
return childpid;
|
||||
}
|
||||
|
||||
free(full_path);
|
||||
return -1; /*NOT REACHED */
|
||||
}
|
||||
|
||||
|
||||
int wait0(pid_t pid)
|
||||
{
|
||||
int status;
|
||||
int val = -1;
|
||||
|
||||
if (pid < 0 || waitpid(pid, &status, 0) < 0)
|
||||
return -1;
|
||||
|
||||
if (WIFEXITED(status)) {
|
||||
val = WEXITSTATUS(status);
|
||||
}
|
||||
|
||||
return val;
|
||||
}
|
103
core/org.eclipse.cdt.core.aix/library/io.c
Normal file
103
core/org.eclipse.cdt.core.aix/library/io.c
Normal file
|
@ -0,0 +1,103 @@
|
|||
#include <jni.h>
|
||||
#include <stdio.h>
|
||||
#include <SpawnerInputStream.h>
|
||||
#include <SpawnerOutputStream.h>
|
||||
#include <unistd.h>
|
||||
|
||||
/* Header for class _org_eclipse_cdt_utils_spawner_SpawnerInputStream */
|
||||
/* Header for class _org_eclipse_cdt_utils_spawner_SpawnerOutputStream */
|
||||
|
||||
/*
|
||||
* Class: org_eclipse_cdt_utils_spawner_SpawnerInputStream
|
||||
* Method: read0
|
||||
* Signature: (I)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_org_eclipse_cdt_utils_spawner_SpawnerInputStream_read0(JNIEnv * env,
|
||||
jobject jobj,
|
||||
jint jfd,
|
||||
jbyteArray buf,
|
||||
jint buf_len)
|
||||
{
|
||||
int fd;
|
||||
int status;
|
||||
jbyte *data;
|
||||
int data_len;
|
||||
|
||||
data = (*env)->GetByteArrayElements(env, buf, 0);
|
||||
data_len = buf_len;
|
||||
fd = jfd;
|
||||
|
||||
status = read( fd, data, data_len );
|
||||
(*env)->ReleaseByteArrayElements(env, buf, data, 0);
|
||||
|
||||
if (status == 0) {
|
||||
/* EOF. */
|
||||
status = -1;
|
||||
} else if (status == -1) {
|
||||
/* Error, toss an exception */
|
||||
jclass exception = (*env)->FindClass(env, "java/io/IOException");
|
||||
if (exception == NULL) {
|
||||
/* Give up. */
|
||||
return -1;
|
||||
}
|
||||
(*env)->ThrowNew(env, exception, "read error");
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Class: org_eclipse_cdt_utils_spawner_SpawnerInputStream
|
||||
* Method: close0
|
||||
* Signature: (I)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_org_eclipse_cdt_utils_spawner_SpawnerInputStream_close0(JNIEnv * env,
|
||||
jobject jobj,
|
||||
jint fd)
|
||||
{
|
||||
return close(fd);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_eclipse_cdt_utils_spawner_SpawnerOutputStream
|
||||
* Method: write0
|
||||
* Signature: (II)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_org_eclipse_cdt_utils_spawner_SpawnerOutputStream_write0(JNIEnv * env,
|
||||
jobject jobj,
|
||||
jint jfd,
|
||||
jbyteArray buf,
|
||||
jint buf_len)
|
||||
{
|
||||
int status;
|
||||
int fd;
|
||||
jbyte *data;
|
||||
int data_len;
|
||||
|
||||
data = (*env)->GetByteArrayElements(env, buf, 0);
|
||||
data_len = buf_len;
|
||||
fd = jfd;
|
||||
|
||||
status = write(fd, data, data_len);
|
||||
(*env)->ReleaseByteArrayElements(env, buf, data, 0);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Class: org_eclipse_cdt_utils_spawner_SpawnerOutputStream
|
||||
* Method: close0
|
||||
* Signature: (I)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_org_eclipse_cdt_utils_spawner_SpawnerOutputStream_close0(JNIEnv * env,
|
||||
jobject jobj,
|
||||
jint fd)
|
||||
{
|
||||
return close(fd);
|
||||
}
|
105
core/org.eclipse.cdt.core.aix/library/openpty.c
Normal file
105
core/org.eclipse.cdt.core.aix/library/openpty.c
Normal file
|
@ -0,0 +1,105 @@
|
|||
/*
|
||||
* (c) Copyright QNX Software Systems Ltd. 2002.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <fcntl.h>
|
||||
#include <termios.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <grp.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stropts.h>
|
||||
|
||||
/**
|
||||
* This is taken from R. W. Stevens book.
|
||||
* Alain Magloire.
|
||||
*/
|
||||
|
||||
int ptym_open (char *pts_name);
|
||||
int ptys_open (int fdm, char * pts_name);
|
||||
|
||||
int
|
||||
openpty(int *amaster, int *aslave, char *name, struct termios *termp, struct winsize *winp)
|
||||
{
|
||||
char line[20];
|
||||
line[0]=0;
|
||||
*amaster = ptym_open(line);
|
||||
if (*amaster < 0)
|
||||
return -1;
|
||||
*aslave = ptys_open(*amaster, line);
|
||||
if (*aslave < 0) {
|
||||
close(*amaster);
|
||||
return -1;
|
||||
}
|
||||
if (name)
|
||||
strcpy(name, line);
|
||||
#ifndef TCSAFLUSH
|
||||
#define TCSAFLUSH TCSETAF
|
||||
#endif
|
||||
if (termp)
|
||||
(void) tcsetattr(*aslave, TCSAFLUSH, termp);
|
||||
#ifdef TIOCSWINSZ
|
||||
if (winp)
|
||||
(void) ioctl(*aslave, TIOCSWINSZ, (char *)winp);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
ptym_open(char * pts_name)
|
||||
{
|
||||
int fdm;
|
||||
char *ptr;
|
||||
|
||||
strcpy(pts_name, "/dev/ptmx");
|
||||
fdm = getpt();
|
||||
if (fdm < 0)
|
||||
return -1;
|
||||
if (grantpt(fdm) < 0) { /* grant access to slave */
|
||||
close(fdm);
|
||||
return -2;
|
||||
}
|
||||
if (unlockpt(fdm) < 0) { /* clear slave's lock flag */
|
||||
close(fdm);
|
||||
return -3;
|
||||
}
|
||||
ptr = ptsname(fdm);
|
||||
if (ptr == NULL) { /* get slave's name */
|
||||
close (fdm);
|
||||
return -4;
|
||||
}
|
||||
strcpy(pts_name, ptr); /* return name of slave */
|
||||
return fdm; /* return fd of master */
|
||||
}
|
||||
|
||||
int
|
||||
ptys_open(int fdm, char * pts_name)
|
||||
{
|
||||
int fds;
|
||||
/* following should allocate controlling terminal */
|
||||
fds = open(pts_name, O_RDWR);
|
||||
if (fds < 0) {
|
||||
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;
|
||||
}
|
||||
return fds;
|
||||
}
|
10
core/org.eclipse.cdt.core.aix/library/openpty.h
Normal file
10
core/org.eclipse.cdt.core.aix/library/openpty.h
Normal file
|
@ -0,0 +1,10 @@
|
|||
/*
|
||||
* (c) Copyright QNX Software Systems Ltd. 2002.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
#ifndef _OPENPTY_H
|
||||
#define _OPENPTY_H
|
||||
int ptym_open (char *pts_name);
|
||||
int ptys_open (int fdm, char * pts_name);
|
||||
#endif
|
78
core/org.eclipse.cdt.core.aix/library/pfind.c
Normal file
78
core/org.eclipse.cdt.core.aix/library/pfind.c
Normal file
|
@ -0,0 +1,78 @@
|
|||
/*
|
||||
* pfind.c - Search for a binary in $PATH.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <limits.h>
|
||||
|
||||
#ifndef PATH_MAX
|
||||
#define PATH_MAX 1024
|
||||
#endif
|
||||
|
||||
|
||||
char * pfind(const char *name)
|
||||
{
|
||||
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 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) {
|
||||
return strdup(name);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Search in the PATH environment. */
|
||||
path = getenv("PATH" );
|
||||
|
||||
if (path == NULL || strlen(path) <= 0) {
|
||||
fprintf(stderr, "Unable to get $PATH.\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* 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) {
|
||||
free(path);
|
||||
return strdup(fullpath);
|
||||
}
|
||||
|
||||
tok = strtok_r( NULL, ":", &sp );
|
||||
}
|
||||
|
||||
free(path);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#ifdef BUILD_WITH_MAIN
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int i;
|
||||
char *fullpath;
|
||||
|
||||
for (i=1; i<argc; i++) {
|
||||
fullpath = pfind(argv[i]);
|
||||
if (fullpath == NULL)
|
||||
printf("Unable to find %s in $PATH.\n", argv[i]);
|
||||
else
|
||||
printf("Found %s @ %s.\n", argv[i], fullpath);
|
||||
}
|
||||
}
|
||||
#endif
|
35
core/org.eclipse.cdt.core.aix/library/pty.c
Normal file
35
core/org.eclipse.cdt.core.aix/library/pty.c
Normal file
|
@ -0,0 +1,35 @@
|
|||
#include "PTY.h"
|
||||
#include "openpty.h"
|
||||
|
||||
/*
|
||||
* Class: org_eclipse_cdt_utils_pty_PTY
|
||||
* Method: forkpty
|
||||
* Signature: ()I
|
||||
*/
|
||||
JNIEXPORT jstring JNICALL
|
||||
Java_org_eclipse_cdt_utils_pty_PTY_forkpty (JNIEnv *env, jobject jobj) {
|
||||
jfieldID fid; /* Store the field ID */
|
||||
jstring jstr = NULL;
|
||||
int master = -1;
|
||||
char line[1024]; /* FIXME: Should be enough */
|
||||
jclass cls;
|
||||
|
||||
line[0] = '\0';
|
||||
|
||||
master = ptym_open(line);
|
||||
if (master >= 0) {
|
||||
/* Get a reference to the obj's class */
|
||||
cls = (*env)->GetObjectClass(env, jobj);
|
||||
|
||||
/* Set the master fd. */
|
||||
fid = (*env)->GetFieldID(env, cls, "master", "I");
|
||||
if (fid == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
(*env)->SetIntField(env, jobj, fid, (jint)master);
|
||||
|
||||
/* Create a new String for the slave. */
|
||||
jstr = (*env)->NewStringUTF(env, line);
|
||||
}
|
||||
return jstr;
|
||||
}
|
107
core/org.eclipse.cdt.core.aix/library/ptyio.c
Normal file
107
core/org.eclipse.cdt.core.aix/library/ptyio.c
Normal file
|
@ -0,0 +1,107 @@
|
|||
#include <jni.h>
|
||||
#include <stdio.h>
|
||||
#include <PTYInputStream.h>
|
||||
#include <PTYOutputStream.h>
|
||||
#include <unistd.h>
|
||||
|
||||
/* Header for class _org_eclipse_cdt_utils_pty_PTYInputStream */
|
||||
/* Header for class _org_eclipse_cdt_utils_pty_PTYOutputStream */
|
||||
|
||||
/*
|
||||
* Class: org_eclipse_cdt_utils_pty_PTYInputStream
|
||||
* Method: read0
|
||||
* Signature: (I)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_org_eclipse_cdt_utils_pty_PTYInputStream_read0(JNIEnv * env,
|
||||
jobject jobj,
|
||||
jint jfd,
|
||||
jbyteArray buf,
|
||||
jint buf_len)
|
||||
{
|
||||
int fd;
|
||||
int status;
|
||||
jbyte *data;
|
||||
int data_len;
|
||||
|
||||
data = (*env)->GetByteArrayElements(env, buf, 0);
|
||||
data_len = buf_len;
|
||||
fd = jfd;
|
||||
|
||||
status = read( fd, data, data_len );
|
||||
(*env)->ReleaseByteArrayElements(env, buf, data, 0);
|
||||
|
||||
if (status == 0) {
|
||||
/* EOF. */
|
||||
status = -1;
|
||||
} else if (status == -1) {
|
||||
/* Error, toss an exception */
|
||||
/* Ignore the error for now, the debugger will attempt
|
||||
* to close this multiple time. */
|
||||
#if 0
|
||||
jclass exception = (*env)->FindClass(env, "java/io/IOException");
|
||||
if (exception == NULL) {
|
||||
/* Give up. */
|
||||
return -1;
|
||||
}
|
||||
(*env)->ThrowNew(env, exception, "read error");
|
||||
#endif
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Class: org_eclipse_cdt_utils_pty_PTYInputStream
|
||||
* Method: close0
|
||||
* Signature: (I)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_org_eclipse_cdt_utils_pty_PTYInputStream_close0(JNIEnv * env,
|
||||
jobject jobj,
|
||||
jint fd)
|
||||
{
|
||||
return close(fd);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_eclipse_cdt_utils_pty_PTYOutputStream
|
||||
* Method: write0
|
||||
* Signature: (II)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_org_eclipse_cdt_utils_pty_PTYOutputStream_write0(JNIEnv * env,
|
||||
jobject jobj,
|
||||
jint jfd,
|
||||
jbyteArray buf,
|
||||
jint buf_len)
|
||||
{
|
||||
int status;
|
||||
int fd;
|
||||
jbyte *data;
|
||||
int data_len;
|
||||
|
||||
data = (*env)->GetByteArrayElements(env, buf, 0);
|
||||
data_len = buf_len;
|
||||
fd = jfd;
|
||||
|
||||
status = write(fd, data, data_len);
|
||||
(*env)->ReleaseByteArrayElements(env, buf, data, 0);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Class: org_eclipse_cdt_utils_pty_PTYOutputStream
|
||||
* Method: close0
|
||||
* Signature: (I)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_org_eclipse_cdt_utils_pty_PTYOutputStream_close0(JNIEnv * env,
|
||||
jobject jobj,
|
||||
jint fd)
|
||||
{
|
||||
return close(fd);
|
||||
}
|
218
core/org.eclipse.cdt.core.aix/library/spawner.c
Normal file
218
core/org.eclipse.cdt.core.aix/library/spawner.c
Normal file
|
@ -0,0 +1,218 @@
|
|||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <signal.h>
|
||||
#include <string.h>
|
||||
#include <jni.h>
|
||||
|
||||
#include "exec0.h"
|
||||
#include <Spawner.h>
|
||||
|
||||
|
||||
#define DEBUGIT 0
|
||||
|
||||
|
||||
/*
|
||||
* Header for class org_eclipse_cdt_utils_spawner_Spawner
|
||||
*/
|
||||
|
||||
|
||||
#if DEBUGIT
|
||||
static void print_array(char **c_array)
|
||||
{
|
||||
if (c_array) {
|
||||
char **p = c_array;
|
||||
for (; *p; p++) {
|
||||
if (*p) {
|
||||
fprintf(stderr, " %s", *p);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
fprintf(stderr, "null");
|
||||
}
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
static char **alloc_c_array(JNIEnv * env, jobjectArray j_array)
|
||||
{
|
||||
int i;
|
||||
jint c_array_size = (*env)->GetArrayLength(env, j_array);
|
||||
char **c_array = calloc(c_array_size + 1, sizeof(*c_array));
|
||||
|
||||
if (c_array == NULL)
|
||||
return NULL;
|
||||
|
||||
for (i = 0; i < c_array_size; i++) {
|
||||
jstring j_str =
|
||||
(jstring) (*env)->GetObjectArrayElement(env, j_array, i);
|
||||
const char *c_str = (*env)->GetStringUTFChars(env, j_str, NULL);
|
||||
c_array[i] = (char *) strdup(c_str);
|
||||
(*env)->ReleaseStringUTFChars(env, j_str, c_str);
|
||||
(*env)->DeleteLocalRef(env, j_str);
|
||||
}
|
||||
|
||||
return c_array;
|
||||
}
|
||||
|
||||
|
||||
static void free_c_array(char **c_array)
|
||||
{
|
||||
if (c_array) {
|
||||
char **p = c_array;
|
||||
for (; *p; p++) {
|
||||
if (*p) {
|
||||
free(*p);
|
||||
}
|
||||
}
|
||||
free(c_array);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_org_eclipse_cdt_utils_spawner_Spawner_exec1(JNIEnv * env, jobject jobj,
|
||||
jobjectArray jcmd,
|
||||
jobjectArray jenv,
|
||||
jstring jdir)
|
||||
{
|
||||
const char *dirpath = (*env)->GetStringUTFChars(env, jdir, NULL);
|
||||
char **cmd;
|
||||
char **envp;
|
||||
pid_t pid = -1;
|
||||
|
||||
cmd = alloc_c_array(env, jcmd);
|
||||
if (cmd == NULL)
|
||||
goto bail_out;
|
||||
|
||||
envp = alloc_c_array(env, jenv);
|
||||
if (envp == NULL)
|
||||
goto bail_out;
|
||||
|
||||
#if DEBUGIT
|
||||
fprintf(stderr, "command:");
|
||||
print_array(cmd);
|
||||
fprintf(stderr, "Envp:");
|
||||
print_array(envp);
|
||||
fprintf(stderr, "dirpath: %s\n", dirpath);
|
||||
#endif
|
||||
|
||||
pid = exec0(cmd[0], cmd, envp, dirpath, NULL);
|
||||
if (pid < 0)
|
||||
goto bail_out;
|
||||
|
||||
bail_out:
|
||||
(*env)->ReleaseStringUTFChars(env, jdir, dirpath);
|
||||
if (cmd)
|
||||
free_c_array(cmd);
|
||||
if (envp)
|
||||
free_c_array(envp);
|
||||
return pid;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_eclipse_cdt_utils_spawner_Spawner
|
||||
* Method: exec0
|
||||
* Signature: ([Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;[I)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_org_eclipse_cdt_utils_spawner_Spawner_exec0(JNIEnv * env, jobject jobj,
|
||||
jobjectArray jcmd,
|
||||
jobjectArray jenv,
|
||||
jstring jdir,
|
||||
jintArray jchannels)
|
||||
{
|
||||
jint *channels = (*env)->GetIntArrayElements(env, jchannels, 0);
|
||||
const char *dirpath = (*env)->GetStringUTFChars(env, jdir, NULL);
|
||||
char **cmd;
|
||||
char **envp;
|
||||
int fd[3];
|
||||
pid_t pid = -1;
|
||||
|
||||
if (channels == NULL)
|
||||
goto bail_out;
|
||||
|
||||
cmd = alloc_c_array(env, jcmd);
|
||||
if (cmd == NULL)
|
||||
goto bail_out;
|
||||
|
||||
envp = alloc_c_array(env, jenv);
|
||||
if (envp == NULL)
|
||||
goto bail_out;
|
||||
|
||||
#if DEBUGIT
|
||||
fprintf(stderr, "command:");
|
||||
print_array(cmd);
|
||||
fprintf(stderr, "Envp:");
|
||||
print_array(envp);
|
||||
fprintf(stderr, "dirpath: %s\n", dirpath);
|
||||
#endif
|
||||
|
||||
pid = exec0(cmd[0], cmd, envp, dirpath, fd);
|
||||
if (pid < 0)
|
||||
goto bail_out;
|
||||
|
||||
channels[0] = fd[0];
|
||||
channels[1] = fd[1];
|
||||
channels[2] = fd[2];
|
||||
|
||||
bail_out:
|
||||
(*env)->ReleaseIntArrayElements(env, jchannels, channels, 0);
|
||||
(*env)->ReleaseStringUTFChars(env, jdir, dirpath);
|
||||
if (cmd)
|
||||
free_c_array(cmd);
|
||||
if (envp)
|
||||
free_c_array(envp);
|
||||
return pid;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_eclipse_cdt_utils_spawner_Spawner
|
||||
* Method: raise
|
||||
* Signature: (II)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_org_eclipse_cdt_utils_spawner_Spawner_raise(JNIEnv * env, jobject jobj,
|
||||
jint pid, jint sig)
|
||||
{
|
||||
int status = -1;
|
||||
|
||||
switch (sig) {
|
||||
case 0: /* NOOP */
|
||||
status = kill(pid, 0);
|
||||
break;
|
||||
|
||||
case 2: /* INTERRUPT */
|
||||
status = kill(pid, SIGINT);
|
||||
break;
|
||||
|
||||
case 9: /* KILL */
|
||||
status = kill(pid, SIGKILL);
|
||||
break;
|
||||
|
||||
case 15: /* TERM */
|
||||
status = kill(pid, SIGTERM);
|
||||
break;
|
||||
|
||||
default:
|
||||
status = kill(pid, sig); /* WHAT ?? */
|
||||
break;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Class: org_eclipse_cdt_utils_spawner_Spawner
|
||||
* Method: waitFor
|
||||
* Signature: (I)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_org_eclipse_cdt_utils_spawner_Spawner_waitFor(JNIEnv * env,
|
||||
jobject jobj, jint pid)
|
||||
{
|
||||
return wait0(pid);
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
package org.eclipse.cdt.internal.core.aix;
|
||||
|
||||
import org.eclipse.cdt.core.IProcessInfo;
|
||||
|
||||
/**
|
||||
* @author alain
|
||||
*
|
||||
* To change this generated comment edit the template variable "typecomment":
|
||||
* Window>Preferences>Java>Templates.
|
||||
* To enable and disable the creation of type comments go to
|
||||
* Window>Preferences>Java>Code Generation.
|
||||
*/
|
||||
public class ProcessInfo implements IProcessInfo {
|
||||
|
||||
int pid;
|
||||
String name;
|
||||
|
||||
public ProcessInfo(String pidString, String name) {
|
||||
try {
|
||||
pid = Integer.parseInt(pidString);
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public ProcessInfo(int pid, String name) {
|
||||
this.pid = pid;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.cdt.core.IProcessInfo#getName()
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.cdt.core.IProcessInfo#getPid()
|
||||
*/
|
||||
public int getPid() {
|
||||
return pid;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,72 @@
|
|||
package org.eclipse.cdt.internal.core.aix;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.FilenameFilter;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.eclipse.cdt.core.IProcessInfo;
|
||||
import org.eclipse.cdt.core.IProcessList;
|
||||
|
||||
/**
|
||||
* Insert the type's description here.
|
||||
* @see IProcessList
|
||||
*/
|
||||
public class ProcessList implements IProcessList {
|
||||
|
||||
ProcessInfo[] empty = new ProcessInfo[0];
|
||||
|
||||
public ProcessList() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert the method's description here.
|
||||
* @see IProcessList#getProcessList
|
||||
*/
|
||||
public IProcessInfo [] getProcessList() {
|
||||
File proc = new File("/proc");
|
||||
File[] pidFiles = null;
|
||||
|
||||
// We are only interrested in the pid so filter the rest out.
|
||||
try {
|
||||
FilenameFilter filter = new FilenameFilter() {
|
||||
public boolean accept(File dir, String name) {
|
||||
boolean isPID = false;
|
||||
try {
|
||||
Integer.parseInt(name);
|
||||
isPID = true;
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
return isPID;
|
||||
}
|
||||
};
|
||||
pidFiles = proc.listFiles(filter);
|
||||
} catch (SecurityException e) {
|
||||
}
|
||||
|
||||
ProcessInfo[] processInfo = empty;
|
||||
if (pidFiles != null) {
|
||||
processInfo = new ProcessInfo[pidFiles.length];
|
||||
for (int i = 0; i < pidFiles.length; i++) {
|
||||
File cmdLine = new File(pidFiles[i], "cmdline");
|
||||
StringBuffer line = new StringBuffer();
|
||||
try {
|
||||
FileReader reader = new FileReader(cmdLine);
|
||||
int c;
|
||||
while ((c = reader.read()) > 0) {
|
||||
line.append((char)c);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
}
|
||||
String name = line.toString();
|
||||
if (name.length() == 0) {
|
||||
name = "Unknown";
|
||||
}
|
||||
processInfo[i] = new ProcessInfo(pidFiles[i].getName(), name);
|
||||
}
|
||||
} else {
|
||||
pidFiles = new File[0];
|
||||
}
|
||||
return processInfo;
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue