2 #include "threadexec.h"
16 ThreadExec::ThreadExec()
19 Thread::set_synchronous(1);
20 arguments = new char*[MAX_ARGS];
22 start_lock = new Mutex;
28 ThreadExec::~ThreadExec()
40 for(int i = 0; i < total_arguments; i++)
41 delete [] arguments[i];
49 void ThreadExec::start_command(char *command_line, int pipe_stdin)
51 this->command_line = command_line;
52 this->pipe_stdin = pipe_stdin;
62 void ThreadExec::run()
67 char argument[BCTEXTLEN];
68 char command_line[BCTEXTLEN];
70 strcpy(command_line, this->command_line);
74 // Set up arguments for exec
77 while(*ptr != ' ' && *ptr != 0)
83 arguments[total_arguments] = new char[strlen(path) + 1];
84 strcpy(arguments[total_arguments], path);
85 //printf("%s\n", arguments[total_arguments]);
87 arguments[total_arguments] = 0;
92 argument_ptr = argument;
93 while(*ptr != ' ' && *ptr != 0)
95 *argument_ptr++ = *ptr++;
98 //printf("%s\n", argument);
100 arguments[total_arguments] = new char[strlen(argument) + 1];
101 strcpy(arguments[total_arguments], argument);
103 arguments[total_arguments] = 0;
118 stdin_fd = fdopen(filedes[1], "w");
121 start_lock->unlock();
123 printf("ThreadExec::run 1\n");
124 run_program(total_arguments, arguments, filedes[0]);
126 printf("ThreadExec::run 2\n");
132 FILE* ThreadExec::get_stdin()
139 void ThreadExec::run_program(int argc, char *argv[], int stdin_fd)
145 // c-file-style: "linux"