mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-05 16:56:04 +02:00
Patch from Gene Sally. And formatting "fixes".
This commit is contained in:
parent
8051af4120
commit
b4b7151cf3
2 changed files with 100 additions and 94 deletions
|
@ -1,6 +1,16 @@
|
|||
# makefile for libspawner.so
|
||||
|
||||
#set JDK_INCLUDES
|
||||
# set JDK_INCLUDES if they are not already set in the environment
|
||||
# spit out a warning if the make script will be using the default values
|
||||
ifeq ($(JDK_INCLUDES),)
|
||||
$(warning JDK_INCLUDES not set in environment, using default: $(JDK_INCLUDES))
|
||||
endif
|
||||
|
||||
ifeq ($(JDK_OS_INCLUDES),)
|
||||
$(warning JDK_OS_INCLUDES not set in environment, using default: $(JDK_OS_INCLUDES))
|
||||
endif
|
||||
|
||||
|
||||
JDK_INCLUDES=/usr/local/jdk/include
|
||||
JDK_OS_INCLUDES=/usr/local/jdk/include/linux
|
||||
|
||||
|
@ -20,12 +30,14 @@ OBJS = $(OBJS_SPAWNER) $(OBJS_PTY)
|
|||
|
||||
all: $(LIB_NAME_FULL_SPAWNER) $(LIB_NAME_FULL_PTY)
|
||||
|
||||
$(LIB NAME_FULL_SPAWNER) : $(OBJS_SPAWNER)
|
||||
rebuild: clean all
|
||||
|
||||
$(LIB_NAME_FULL_SPAWNER) : $(OBJS_SPAWNER)
|
||||
$(CC) -g -shared -Wl,-soname,$(LIB_NAME_SPAWNER) -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)
|
||||
|
||||
clean :
|
||||
echo -rm $(OBJS_SPAWNER) $(LIB_NAME_FULL_SPAWNER)
|
||||
-rm $(OBJS_PTY) $(LIB_NAME_FULL_PTY)
|
||||
$(RM) $(OBJS_SPAWNER) $(LIB_NAME_FULL_SPAWNER)
|
||||
$(RM) $(OBJS_PTY) $(LIB_NAME_FULL_PTY)
|
||||
|
|
|
@ -18,25 +18,24 @@ exec0(const char *path, char *const argv[], char *const envp[],
|
|||
pid_t childpid;
|
||||
char *full_path;
|
||||
|
||||
//
|
||||
// Handle this error case, we need the full path for execve() below.
|
||||
//
|
||||
/*
|
||||
* Handle this error case, we need the full path for execve() below.
|
||||
*/
|
||||
if (path[0] != '/' && path[0] != '.') {
|
||||
full_path = pfind( path );
|
||||
full_path = pfind(path);
|
||||
//full_path = pathfind (getenv ("PATH"), path, "rx");
|
||||
if (full_path == NULL) {
|
||||
fprintf( stderr, "Unable to find full path for \"%s\"\n", path );
|
||||
fprintf(stderr, "Unable to find full path for \"%s\"\n", path );
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
full_path = path;
|
||||
full_path = strdup(path);
|
||||
}
|
||||
|
||||
//
|
||||
// Make sure we can create our pipes before forking.
|
||||
//
|
||||
if( channels != NULL )
|
||||
{
|
||||
/*
|
||||
* 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__);
|
||||
|
@ -57,19 +56,18 @@ exec0(const char *path, char *const argv[], char *const envp[],
|
|||
|
||||
chdir(dirpath);
|
||||
|
||||
if( channels != NULL )
|
||||
{
|
||||
if (channels != NULL) {
|
||||
/* Close the write end of pipe0 */
|
||||
if( close(pipe0[1]) == -1 )
|
||||
perror( "close(pipe0[1])" );
|
||||
if (close(pipe0[1]) == -1)
|
||||
perror("close(pipe0[1])");
|
||||
|
||||
/* Close the read end of pipe1 */
|
||||
if( close(pipe1[0]) == -1 )
|
||||
perror( "close(pipe1[0])" );
|
||||
if (close(pipe1[0]) == -1)
|
||||
perror("close(pipe1[0])");
|
||||
|
||||
/* Close the read end of pipe2 */
|
||||
if( close(pipe2[0]) == -1 )
|
||||
perror( "close(pipe2[0]))" );
|
||||
if (close(pipe2[0]) == -1)
|
||||
perror("close(pipe2[0]))");
|
||||
|
||||
/* redirections */
|
||||
dup2(pipe0[0], STDIN_FILENO); /* dup stdin */
|
||||
|
@ -86,13 +84,10 @@ exec0(const char *path, char *const argv[], char *const envp[],
|
|||
close(fd++);
|
||||
}
|
||||
|
||||
if( envp[0] == NULL )
|
||||
{
|
||||
execv( full_path, argv );
|
||||
}
|
||||
else
|
||||
{
|
||||
execve( full_path, argv, envp );
|
||||
if (envp[0] == NULL) {
|
||||
execv(full_path, argv);
|
||||
} else {
|
||||
execve(full_path, argv, envp);
|
||||
}
|
||||
|
||||
_exit(127);
|
||||
|
@ -101,19 +96,18 @@ exec0(const char *path, char *const argv[], char *const envp[],
|
|||
|
||||
char b;
|
||||
|
||||
if( channels != NULL )
|
||||
{
|
||||
if (channels != NULL) {
|
||||
/* close the read end of pipe1 */
|
||||
if( close(pipe0[0]) == -1 )
|
||||
perror( "close(pipe0[0])" );
|
||||
if (close(pipe0[0]) == -1)
|
||||
perror("close(pipe0[0])");
|
||||
|
||||
/* close the write end of pipe2 */
|
||||
if( close(pipe1[1]) == -1 )
|
||||
perror( "close(pipe1[1])" );
|
||||
if (close(pipe1[1]) == -1)
|
||||
perror("close(pipe1[1])");
|
||||
|
||||
/* close the write end of pipe2 */
|
||||
if( close(pipe2[1]) == -1 )
|
||||
perror( "close(pipe2[1])" );
|
||||
if (close(pipe2[1]) == -1)
|
||||
perror("close(pipe2[1])");
|
||||
|
||||
channels[0] = pipe0[1]; /* Output Stream. */
|
||||
channels[1] = pipe1[0]; /* Input Stream. */
|
||||
|
|
Loading…
Add table
Reference in a new issue