git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@5903
48e7efb5-ca39-0410-a469-
dd3cf9ba447f
csr_outputs_dont_match = 12,
csr_signals_dont_match = 13,
csr_unexpected_signal_caught = 14,
csr_outputs_dont_match = 12,
csr_signals_dont_match = 13,
csr_unexpected_signal_caught = 14,
- csr_expected_signal_not_receipt = 15,
+ csr_expected_signal_not_received = 15,
csr_pipe_function_failed = 16, /* the function pipe() or CreatePipe() fails */
csr_dup2_function_failure = 17,
csr_execlp_function_failure = 18,
csr_pipe_function_failed = 16, /* the function pipe() or CreatePipe() fails */
csr_dup2_function_failure = 17,
csr_execlp_function_failure = 18,
#define EOUTPUTNOTMATCH ((int)109) /* the outputs don't match */\r
#define ESIGNOTMATCH ((int)110) /* the signals don't match */\r
#define EUNXPSIG ((int)111) /* Unexpected signal caught */\r
#define EOUTPUTNOTMATCH ((int)109) /* the outputs don't match */\r
#define ESIGNOTMATCH ((int)110) /* the signals don't match */\r
#define EUNXPSIG ((int)111) /* Unexpected signal caught */\r
-#define ESIGNOTRECEIPT ((int)112) /* the expected signal is not receipt */\r
+#define ESIGNOTRECEIVED ((int)112) /* the expected signal is not receipt */\r
#define EPROCCMDLINE ((int)116) /* this is an internal error : the process_command_line() function failed */\r
#define ENOARG ((int)117) /* a none optional argument is not specified in the command line */\r
#define ENOTPOSITIVENUM ((int)118) /* the argument of the option is not strictly positive */\r
#define EPROCCMDLINE ((int)116) /* this is an internal error : the process_command_line() function failed */\r
#define ENOARG ((int)117) /* a none optional argument is not specified in the command line */\r
#define ENOTPOSITIVENUM ((int)118) /* the argument of the option is not strictly positive */\r
/*\r
* src/command.c - type representing a command.\r
*\r
/*\r
* src/command.c - type representing a command.\r
*\r
- * Copyright 2008,2009 Martin Quinson, Malek Cherier All right reserved. \r
+ * Copyright 2008,2009 Martin Quinson, Malek Cherier All right reserved.\r
- * This program is free software; you can redistribute it and/or modify it \r
+ * This program is free software; you can redistribute it and/or modify it\r
* under the terms of the license (GNU LGPL) which comes with this package.\r
*\r
* Purpose:\r
* under the terms of the license (GNU LGPL) which comes with this package.\r
*\r
* Purpose:\r
static char w32cmd[PATH_MAX + 1] = {0};\r
char cmd_buf[PATH_MAX + 1] = {0};\r
size_t i,j, len;\r
static char w32cmd[PATH_MAX + 1] = {0};\r
char cmd_buf[PATH_MAX + 1] = {0};\r
size_t i,j, len;\r
if(!cmd)\r
{\r
errno = EINVAL;\r
return NULL;\r
}\r
if(!cmd)\r
{\r
errno = EINVAL;\r
return NULL;\r
}\r
/* TODO : if ~*/\r
if(cmd[0] != '.')\r
{\r
strcpy(w32cmd, cmd);\r
return w32cmd;\r
}\r
/* TODO : if ~*/\r
if(cmd[0] != '.')\r
{\r
strcpy(w32cmd, cmd);\r
return w32cmd;\r
}\r
i = j = 0;\r
len = strlen(cmd);\r
i = j = 0;\r
len = strlen(cmd);\r
while(i < len)\r
{\r
if(cmd[i] != ' ' && cmd[i] != '\t' && cmd[i] != '>')\r
cmd_buf[j++] = cmd[i];\r
else\r
break;\r
while(i < len)\r
{\r
if(cmd[i] != ' ' && cmd[i] != '\t' && cmd[i] != '>')\r
cmd_buf[j++] = cmd[i];\r
else\r
break;\r
i++;\r
}\r
\r
_fullpath(w32cmd, cmd_buf, sizeof(w32cmd));\r
i++;\r
}\r
\r
_fullpath(w32cmd, cmd_buf, sizeof(w32cmd));\r
if(!strstr(w32cmd, ".exe"))\r
strcat(w32cmd, ".exe ");\r
if(!strstr(w32cmd, ".exe"))\r
strcat(w32cmd, ".exe ");\r
strcat(w32cmd, cmd + i);\r
strcat(w32cmd, cmd + i);\r
/*printf("w32cmd : %s", w32cmd);*/\r
\r
return w32cmd;\r
/*printf("w32cmd : %s", w32cmd);*/\r
\r
return w32cmd;\r
command_new(unit_t unit, context_t context, xbt_os_mutex_t mutex)\r
{\r
command_t command;\r
command_new(unit_t unit, context_t context, xbt_os_mutex_t mutex)\r
{\r
command_t command;\r
command = xbt_new0(s_command_t, 1);\r
command = xbt_new0(s_command_t, 1);\r
/* get the context of the execution of the command */\r
if(!(command->context = context_dup(context)))\r
{\r
free(command);\r
return NULL;\r
}\r
/* get the context of the execution of the command */\r
if(!(command->context = context_dup(context)))\r
{\r
free(command);\r
return NULL;\r
}\r
/* the exit code of the command is indefinite */\r
command->exit_code = INDEFINITE;\r
/* the exit code of the command is indefinite */\r
command->exit_code = INDEFINITE;\r
/* the signal of the command is indefinite */\r
command->signal = INDEFINITE_SIGNAL;\r
/* the signal of the command is indefinite */\r
command->signal = INDEFINITE_SIGNAL;\r
command->failed = 0;\r
command->interrupted = 0;\r
command->failed = 0;\r
command->interrupted = 0;\r
/* the mutex used to safetly access to the command unit properties */\r
command->mutex = mutex;\r
\r
command->output = xbt_strbuff_new();\r
\r
command->pid = INDEFINITE_PID;\r
/* the mutex used to safetly access to the command unit properties */\r
command->mutex = mutex;\r
\r
command->output = xbt_strbuff_new();\r
\r
command->pid = INDEFINITE_PID;\r
command->stat_val = -1;\r
command->stat_val = -1;\r
/* set the unit of the command */\r
/* set the unit of the command */\r
- command->root = unit->root ? unit->root : unit; \r
+ command->root = unit->root ? unit->root : unit;\r
/* all the commands are runned in a thread */\r
command->thread = NULL;\r
/* all the commands are runned in a thread */\r
command->thread = NULL;\r
command->successeded = 0;\r
command->successeded = 0;\r
command->reader = reader_new(command);\r
\r
if(context->input->used)\r
command->reader = reader_new(command);\r
\r
if(context->input->used)\r
\r
command->status = cs_initialized;\r
command->reason = csr_unknown;\r
\r
command->status = cs_initialized;\r
command->reason = csr_unknown;\r
command->stdin_fd = INDEFINITE_FD;\r
command->stdout_fd = INDEFINITE_FD;\r
command->stdin_fd = INDEFINITE_FD;\r
command->stdout_fd = INDEFINITE_FD;\r
/* register the command */\r
xbt_os_mutex_acquire(mutex);\r
/* register the command */\r
xbt_os_mutex_acquire(mutex);\r
xbt_dynar_push(unit->commands, &command);\r
command->root->cmd_nb++;\r
xbt_os_mutex_release(mutex);\r
xbt_dynar_push(unit->commands, &command);\r
command->root->cmd_nb++;\r
xbt_os_mutex_release(mutex);\r
#ifndef WIN32\r
command->killed = 0;\r
command->execlp_errno = 0;\r
#endif\r
#ifndef WIN32\r
command->killed = 0;\r
command->execlp_errno = 0;\r
#endif\r
{\r
if(!silent_flag && !interrupted)\r
INFO2("[%s] %s",command->context->pos, command->context->command_line);\r
{\r
if(!silent_flag && !interrupted)\r
INFO2("[%s] %s",command->context->pos, command->context->command_line);\r
if(!interrupted)\r
{\r
/* start the command in a thread*/\r
if(command->context->async)\r
{\r
command->thread = xbt_os_thread_create("", command_start, command);\r
if(!interrupted)\r
{\r
/* start the command in a thread*/\r
if(command->context->async)\r
{\r
command->thread = xbt_os_thread_create("", command_start, command);\r
- command_interrupt(command); \r
+ command_interrupt(command);\r
{\r
command_t command = (command_t)p;\r
unit_t root = command->root;\r
{\r
command_t command = (command_t)p;\r
unit_t root = command->root;\r
/* the command is started */\r
command->status = cs_started;\r
/* the command is started */\r
command->status = cs_started;\r
/* increment the number of started commands of the unit */\r
xbt_os_mutex_acquire(command->mutex);\r
(root->started_cmd_nb)++;\r
xbt_os_mutex_release(command->mutex);\r
/* increment the number of started commands of the unit */\r
xbt_os_mutex_acquire(command->mutex);\r
(root->started_cmd_nb)++;\r
xbt_os_mutex_release(command->mutex);\r
/* execute the command of the test */\r
\r
#ifndef WIN32\r
/* execute the command of the test */\r
\r
#ifndef WIN32\r
/* play the translated command line on Windows */\r
command_exec(command, command->context->t_command_line);\r
#endif\r
/* play the translated command line on Windows */\r
command_exec(command, command->context->t_command_line);\r
#endif\r
if(cs_in_progress == command->status)\r
{\r
/* wait the process if it is in progress */\r
command_wait(command);\r
if(cs_in_progress == command->status)\r
{\r
/* wait the process if it is in progress */\r
command_wait(command);\r
if(cs_failed != command->status && cs_interrupted != command->status)\r
command_check(command);\r
}\r
if(cs_failed != command->status && cs_interrupted != command->status)\r
command_check(command);\r
}\r
xbt_os_mutex_acquire(command->mutex);\r
xbt_os_mutex_acquire(command->mutex);\r
/* if it's the last command of the root unit */\r
if(!root->interrupted && root->parsed && (root->started_cmd_nb == (root->failed_cmd_nb + root->interrupted_cmd_nb + root->successeded_cmd_nb)))\r
{\r
/* if it's the last command of the root unit */\r
if(!root->interrupted && root->parsed && (root->started_cmd_nb == (root->failed_cmd_nb + root->interrupted_cmd_nb + root->successeded_cmd_nb)))\r
{\r
}\r
else\r
xbt_os_mutex_release(command->mutex);\r
}\r
else\r
xbt_os_mutex_release(command->mutex);\r
/* wait the end of the timer, the reader and the writer */\r
if(command->timer && command->timer->thread)\r
timer_wait(command->timer);\r
/* wait the end of the timer, the reader and the writer */\r
if(command->timer && command->timer->thread)\r
timer_wait(command->timer);\r
/* wait the end of the writer */\r
if(command->writer && command->writer->thread)\r
writer_wait(command->writer);\r
/* wait the end of the writer */\r
if(command->writer && command->writer->thread)\r
writer_wait(command->writer);\r
/* wait the end of the reader */\r
if(command->reader && command->reader->thread)\r
reader_wait(command->reader);\r
/* wait the end of the reader */\r
if(command->reader && command->reader->thread)\r
reader_wait(command->reader);\r
void\r
command_exec(command_t command, const char* command_line)\r
{\r
void\r
command_exec(command_t command, const char* command_line)\r
{\r
STARTUPINFO si = {0}; /* contains the informations about the child process windows*/\r
PROCESS_INFORMATION pi = {0}; /* contains child process informations */\r
SECURITY_ATTRIBUTES sa = {0}; /* contains the security descriptor for the pipe handles */\r
HANDLE child_stdin_handle[2] = {NULL}; /* child_stdin_handle[1] <-> stdout of the child process */\r
HANDLE child_stdout_handle[2] = {NULL}; /* child_stdout_handle[0] <-> stdin of the child process */\r
HANDLE child_stderr = NULL;\r
STARTUPINFO si = {0}; /* contains the informations about the child process windows*/\r
PROCESS_INFORMATION pi = {0}; /* contains child process informations */\r
SECURITY_ATTRIBUTES sa = {0}; /* contains the security descriptor for the pipe handles */\r
HANDLE child_stdin_handle[2] = {NULL}; /* child_stdin_handle[1] <-> stdout of the child process */\r
HANDLE child_stdout_handle[2] = {NULL}; /* child_stdout_handle[0] <-> stdin of the child process */\r
HANDLE child_stderr = NULL;\r
\r
sa.nLength = sizeof(SECURITY_ATTRIBUTES);\r
sa.lpSecurityDescriptor = NULL; /* use default security for the pipe handles */\r
\r
sa.nLength = sizeof(SECURITY_ATTRIBUTES);\r
sa.lpSecurityDescriptor = NULL; /* use default security for the pipe handles */\r
sa.bInheritHandle = TRUE; /* the pipe handles can be inherited */\r
sa.bInheritHandle = TRUE; /* the pipe handles can be inherited */\r
if(!CreatePipe(&(child_stdin_handle[0]),&(child_stdin_handle[1]),&sa,0))\r
{\r
ERROR3("[%s] `%s' : NOK (%s)", command->context->pos, command->context->command_line, error_to_string((int)GetLastError(), 0));\r
if(!CreatePipe(&(child_stdin_handle[0]),&(child_stdin_handle[1]),&sa,0))\r
{\r
ERROR3("[%s] `%s' : NOK (%s)", command->context->pos, command->context->command_line, error_to_string((int)GetLastError(), 0));\r
unit_set_error(command->unit, (int)GetLastError(), 0, command->context->pos);\r
\r
command->failed = 1;\r
command->status = cs_failed;\r
unit_set_error(command->unit, (int)GetLastError(), 0, command->context->pos);\r
\r
command->failed = 1;\r
command->status = cs_failed;\r
if(!DuplicateHandle(GetCurrentProcess(),(child_stdin_handle[1]),GetCurrentProcess(),&(child_stderr),0,TRUE,DUPLICATE_SAME_ACCESS))\r
{\r
ERROR3("[%s] `%s' : NOK (%s)", command->context->pos, command->context->command_line, error_to_string((int)GetLastError(), 0));\r
if(!DuplicateHandle(GetCurrentProcess(),(child_stdin_handle[1]),GetCurrentProcess(),&(child_stderr),0,TRUE,DUPLICATE_SAME_ACCESS))\r
{\r
ERROR3("[%s] `%s' : NOK (%s)", command->context->pos, command->context->command_line, error_to_string((int)GetLastError(), 0));\r
unit_set_error(command->unit, (int)GetLastError(), 0, command->context->pos);\r
unit_set_error(command->unit, (int)GetLastError(), 0, command->context->pos);\r
CloseHandle(child_stdin_handle[0]);\r
CloseHandle(child_stdin_handle[1]);\r
\r
command->failed = 1;\r
CloseHandle(child_stdin_handle[0]);\r
CloseHandle(child_stdin_handle[1]);\r
\r
command->failed = 1;\r
- command->status = cs_failed; \r
+ command->status = cs_failed;\r
if(!CreatePipe(&(child_stdout_handle[0]),&(child_stdout_handle[1]),&sa,0))\r
{\r
ERROR3("[%s] `%s' : NOK (%s)", command->context->pos, command->context->command_line, error_to_string((int)GetLastError(), 0));\r
unit_set_error(command->unit, (int)GetLastError(), 0, command->context->pos);\r
if(!CreatePipe(&(child_stdout_handle[0]),&(child_stdout_handle[1]),&sa,0))\r
{\r
ERROR3("[%s] `%s' : NOK (%s)", command->context->pos, command->context->command_line, error_to_string((int)GetLastError(), 0));\r
unit_set_error(command->unit, (int)GetLastError(), 0, command->context->pos);\r
CloseHandle(child_stdout_handle[0]);\r
CloseHandle(child_stdout_handle[1]);\r
CloseHandle(child_stdin_handle[0]);\r
CloseHandle(child_stdin_handle[1]);\r
\r
command->failed = 1;\r
CloseHandle(child_stdout_handle[0]);\r
CloseHandle(child_stdout_handle[1]);\r
CloseHandle(child_stdin_handle[0]);\r
CloseHandle(child_stdin_handle[1]);\r
\r
command->failed = 1;\r
- command->status = cs_failed; \r
+ command->status = cs_failed;\r
/* Read handle for read operations on the child std output. */\r
if(!DuplicateHandle(GetCurrentProcess(),(child_stdin_handle[0]),GetCurrentProcess(),&(command->stdout_fd),0,FALSE, DUPLICATE_SAME_ACCESS))\r
{\r
/* Read handle for read operations on the child std output. */\r
if(!DuplicateHandle(GetCurrentProcess(),(child_stdin_handle[0]),GetCurrentProcess(),&(command->stdout_fd),0,FALSE, DUPLICATE_SAME_ACCESS))\r
{\r
CloseHandle(child_stdin_handle[1]);\r
\r
command->failed = 1;\r
CloseHandle(child_stdin_handle[1]);\r
\r
command->failed = 1;\r
- command->status = cs_failed; \r
- \r
+ command->status = cs_failed;\r
+\r
ERROR3("[%s] `%s' : NOK (%s)", command->context->pos, command->context->command_line, error_to_string((int)GetLastError(), 0));\r
unit_set_error(command->unit, (int)GetLastError(), 0, command->context->pos);\r
ERROR3("[%s] `%s' : NOK (%s)", command->context->pos, command->context->command_line, error_to_string((int)GetLastError(), 0));\r
unit_set_error(command->unit, (int)GetLastError(), 0, command->context->pos);\r
/* Write handle for write operations on the child std input. */\r
if(!DuplicateHandle(GetCurrentProcess(),(child_stdout_handle[1]),GetCurrentProcess(),&(command->stdin_fd), 0,FALSE,DUPLICATE_SAME_ACCESS))\r
{\r
/* Write handle for write operations on the child std input. */\r
if(!DuplicateHandle(GetCurrentProcess(),(child_stdout_handle[1]),GetCurrentProcess(),&(command->stdin_fd), 0,FALSE,DUPLICATE_SAME_ACCESS))\r
{\r
CloseHandle(child_stdin_handle[1]);\r
\r
command->failed = 1;\r
CloseHandle(child_stdin_handle[1]);\r
\r
command->failed = 1;\r
- command->status = cs_failed; \r
- \r
+ command->status = cs_failed;\r
+\r
ERROR3("[%s] `%s' : NOK (%s)", command->context->pos, command->context->command_line, error_to_string((int)GetLastError(), 0));\r
\r
unit_set_error(command->unit, (int)GetLastError(), 0, command->context->pos);\r
\r
return;\r
}\r
ERROR3("[%s] `%s' : NOK (%s)", command->context->pos, command->context->command_line, error_to_string((int)GetLastError(), 0));\r
\r
unit_set_error(command->unit, (int)GetLastError(), 0, command->context->pos);\r
\r
return;\r
}\r
CloseHandle(child_stdin_handle[0]);\r
CloseHandle(child_stdout_handle[1]);\r
\r
CloseHandle(child_stdin_handle[0]);\r
CloseHandle(child_stdout_handle[1]);\r
\r
if(command->timer)\r
{\r
/* launch the timer */\r
timer_time(command->timer);\r
}\r
if(command->timer)\r
{\r
/* launch the timer */\r
timer_time(command->timer);\r
}\r
if(command->reader)\r
{\r
/* launch the reader */\r
reader_read(command->reader);\r
}\r
if(command->reader)\r
{\r
/* launch the reader */\r
reader_read(command->reader);\r
}\r
\r
if(command->writer)\r
{\r
\r
if(command->writer)\r
{\r
/* if there is a reader wait for its starting */\r
if(command->reader)\r
xbt_os_sem_acquire(command->reader->started);\r
/* if there is a reader wait for its starting */\r
if(command->reader)\r
xbt_os_sem_acquire(command->reader->started);\r
/* if there is a reader wait for its ending */\r
if(command->writer)\r
xbt_os_sem_acquire(command->writer->written);\r
/* if there is a reader wait for its ending */\r
if(command->writer)\r
xbt_os_sem_acquire(command->writer->written);\r
/* if there is a reader wait for its starting */\r
if(command->timer)\r
xbt_os_sem_acquire(command->timer->started);\r
\r
si.cb = sizeof(STARTUPINFO);\r
/* if there is a reader wait for its starting */\r
if(command->timer)\r
xbt_os_sem_acquire(command->timer->started);\r
\r
si.cb = sizeof(STARTUPINFO);\r
si.dwFlags |= STARTF_USESTDHANDLES;\r
si.hStdOutput = child_stdin_handle[1];\r
si.hStdInput = child_stdout_handle[0];\r
si.dwFlags |= STARTF_USESTDHANDLES;\r
si.hStdOutput = child_stdin_handle[1];\r
si.hStdInput = child_stdout_handle[0];\r
unit_set_error(command->unit, (int)GetLastError(), 0, command->context->pos);\r
command_handle_failure(command, csr_create_process_function_failure);\r
}\r
unit_set_error(command->unit, (int)GetLastError(), 0, command->context->pos);\r
command_handle_failure(command, csr_create_process_function_failure);\r
}\r
\r
/* close non used thread handle */\r
CloseHandle(pi.hThread);\r
\r
/* close non used thread handle */\r
CloseHandle(pi.hThread);\r
/* close non used handles */\r
CloseHandle(child_stdin_handle[1]);\r
CloseHandle(child_stdout_handle[0]);\r
/* close non used handles */\r
CloseHandle(child_stdin_handle[1]);\r
CloseHandle(child_stdout_handle[0]);\r
{\r
int child_stdin_fd[2] ;\r
int child_stdout_fd[2];\r
{\r
int child_stdin_fd[2] ;\r
int child_stdout_fd[2];\r
#ifdef __CHKCMD\r
int rv = is_cmd(command->unit->runner->path, command->unit->runner->builtin, command_line);\r
\r
#ifdef __CHKCMD\r
int rv = is_cmd(command->unit->runner->path, command->unit->runner->builtin, command_line);\r
\r
}\r
\r
command_handle_failure(command, csr_command_not_found);\r
}\r
\r
command_handle_failure(command, csr_command_not_found);\r
if(command->writer)\r
{\r
if(command->writer)\r
{\r
- if(pipe(child_stdin_fd)) \r
+ if(pipe(child_stdin_fd))\r
{\r
ERROR3("[%s] `%s' : NOK (%s)", command->context->pos, command->context->command_line, error_to_string(errno, 0));\r
{\r
ERROR3("[%s] `%s' : NOK (%s)", command->context->pos, command->context->command_line, error_to_string(errno, 0));\r
unit_set_error(command->unit, errno, 0, command->context->pos);\r
\r
command_handle_failure(command, csr_pipe_function_failed);\r
\r
unit_set_error(command->unit, errno, 0, command->context->pos);\r
\r
command_handle_failure(command, csr_pipe_function_failed);\r
\r
if(command->reader)\r
{\r
if(command->reader)\r
{\r
- if(pipe(child_stdout_fd)) \r
+ if(pipe(child_stdout_fd))\r
{\r
ERROR3("[%s] `%s' : NOK (%s)", command->context->pos, command->context->command_line, error_to_string(errno, 0));\r
{\r
ERROR3("[%s] `%s' : NOK (%s)", command->context->pos, command->context->command_line, error_to_string(errno, 0));\r
if(command->writer)\r
{\r
close(child_stdin_fd[0]);\r
close(child_stdin_fd[1]);\r
}\r
if(command->writer)\r
{\r
close(child_stdin_fd[0]);\r
close(child_stdin_fd[1]);\r
}\r
unit_set_error(command->unit, errno, 0, command->context->pos);\r
\r
command_handle_failure(command, csr_pipe_function_failed);\r
unit_set_error(command->unit, errno, 0, command->context->pos);\r
\r
command_handle_failure(command, csr_pipe_function_failed);\r
if(command->writer)\r
{\r
if(fcntl(child_stdin_fd[1], F_SETFL, fcntl(child_stdin_fd[1], F_GETFL) | O_NONBLOCK) < 0)\r
{\r
\r
ERROR3("[%s] `%s' : NOK (%s)", command->context->pos, command->context->command_line, error_to_string(errno, 0));\r
if(command->writer)\r
{\r
if(fcntl(child_stdin_fd[1], F_SETFL, fcntl(child_stdin_fd[1], F_GETFL) | O_NONBLOCK) < 0)\r
{\r
\r
ERROR3("[%s] `%s' : NOK (%s)", command->context->pos, command->context->command_line, error_to_string(errno, 0));\r
close(child_stdin_fd[0]);\r
close(child_stdin_fd[1]);\r
close(child_stdin_fd[0]);\r
close(child_stdin_fd[1]);\r
if(command->reader)\r
{\r
close(child_stdout_fd[0]);\r
close(child_stdout_fd[1]);\r
}\r
if(command->reader)\r
{\r
close(child_stdout_fd[0]);\r
close(child_stdout_fd[1]);\r
}\r
unit_set_error(command->unit, errno, 0, command->context->pos);\r
\r
unit_set_error(command->unit, errno, 0, command->context->pos);\r
\r
- command_handle_failure(command, csr_fcntl_function_failed); \r
- \r
+ command_handle_failure(command, csr_fcntl_function_failed);\r
+\r
/* to write to the child stdin */\r
command->stdin_fd = child_stdin_fd[1];\r
/* to write to the child stdin */\r
command->stdin_fd = child_stdin_fd[1];\r
/* to read from the child stdout */\r
command->stdout_fd = child_stdout_fd[0];\r
/* to read from the child stdout */\r
command->stdout_fd = child_stdout_fd[0];\r
/* launch the reader if any*/\r
if(command->reader)\r
reader_read(command->reader);\r
/* launch the reader if any*/\r
if(command->reader)\r
reader_read(command->reader);\r
/* launch the writer if any */\r
if(command->writer)\r
writer_write(command->writer);\r
/* launch the writer if any */\r
if(command->writer)\r
writer_write(command->writer);\r
/* launch the timer if any */\r
if(command->timer)\r
timer_time(command->timer);\r
/* launch the timer if any */\r
if(command->timer)\r
timer_time(command->timer);\r
/* if there is a reader wait for its starting */\r
if(command->reader)\r
xbt_os_sem_acquire(command->reader->started);\r
/* if there is a reader wait for its starting */\r
if(command->reader)\r
xbt_os_sem_acquire(command->reader->started);\r
/* if there is a reader wait for its ending */\r
if(command->writer)\r
xbt_os_sem_acquire(command->writer->written);\r
/* if there is a reader wait for its ending */\r
if(command->writer)\r
xbt_os_sem_acquire(command->writer->written);\r
/* if there is a reader wait for its starting */\r
if(command->timer)\r
xbt_os_sem_acquire(command->timer->started);\r
/* if there is a reader wait for its starting */\r
if(command->timer)\r
xbt_os_sem_acquire(command->timer->started);\r
/* update the state of the command, assume it is in progress */\r
command->status = cs_in_progress;\r
/* update the state of the command, assume it is in progress */\r
command->status = cs_in_progress;\r
- \r
- if(command->pid < 0) \r
+\r
+ if(command->pid < 0)\r
{/* error */\r
if(command->writer)\r
{\r
close(child_stdin_fd[0]);\r
close(child_stdin_fd[1]);\r
}\r
{/* error */\r
if(command->writer)\r
{\r
close(child_stdin_fd[0]);\r
close(child_stdin_fd[1]);\r
}\r
if(command->reader)\r
{\r
close(child_stdout_fd[0]);\r
close(child_stdout_fd[1]);\r
}\r
if(command->reader)\r
{\r
close(child_stdout_fd[0]);\r
close(child_stdout_fd[1]);\r
}\r
ERROR2("[%s] Cannot fork the command `%s'", command->context->pos, command->context->command_line);\r
unit_set_error(command->unit, errno, 0, command->context->pos);\r
command_handle_failure(command,csr_fork_function_failure);\r
}\r
else\r
{\r
ERROR2("[%s] Cannot fork the command `%s'", command->context->pos, command->context->command_line);\r
unit_set_error(command->unit, errno, 0, command->context->pos);\r
command_handle_failure(command,csr_fork_function_failure);\r
}\r
else\r
{\r
/* close unused file descriptors */\r
if(command->writer)\r
close(child_stdin_fd[0]);\r
/* close unused file descriptors */\r
if(command->writer)\r
close(child_stdin_fd[0]);\r
if(command->reader)\r
close(child_stdout_fd[1]);\r
if(command->reader)\r
close(child_stdout_fd[1]);\r
/* close unused file descriptors */\r
if(command->writer)\r
close(child_stdin_fd[1]);\r
/* close unused file descriptors */\r
if(command->writer)\r
close(child_stdin_fd[1]);\r
if(command->reader)\r
close(child_stdout_fd[0]);\r
if(command->reader)\r
close(child_stdout_fd[0]);\r
if(command->writer)\r
{\r
if(command->writer)\r
{\r
- /* redirect stdin to child_stdin_fd[0] (now fgets(), getchar() ... read from the pipe */ \r
+ /* redirect stdin to child_stdin_fd[0] (now fgets(), getchar() ... read from the pipe */\r
if(dup2(child_stdin_fd[0],STDIN_FILENO) < 0)\r
{\r
ERROR3("[%s] `%s' : NOK (%s)", command->context->pos, command->context->command_line, error_to_string(errno, 0));\r
if(dup2(child_stdin_fd[0],STDIN_FILENO) < 0)\r
{\r
ERROR3("[%s] `%s' : NOK (%s)", command->context->pos, command->context->command_line, error_to_string(errno, 0));\r
unit_set_error(command->unit, errno, 0, command->context->pos);\r
command_handle_failure(command,csr_dup2_function_failure);\r
}\r
unit_set_error(command->unit, errno, 0, command->context->pos);\r
command_handle_failure(command,csr_dup2_function_failure);\r
}\r
/* close the unused file descriptor */\r
close(child_stdin_fd[0]);\r
}\r
/* close the unused file descriptor */\r
close(child_stdin_fd[0]);\r
}\r
if(command->reader)\r
{\r
if(command->reader)\r
{\r
- \r
- /* redirect stdout and stderr to child_stdout_fd[1] (now printf(), perror()... write to the pipe */ \r
+\r
+ /* redirect stdout and stderr to child_stdout_fd[1] (now printf(), perror()... write to the pipe */\r
if(dup2(child_stdout_fd[1],STDOUT_FILENO) < 0)\r
{\r
ERROR3("[%s] `%s' : NOK (%s)", command->context->pos, command->context->command_line, error_to_string(errno, 0));\r
if(dup2(child_stdout_fd[1],STDOUT_FILENO) < 0)\r
{\r
ERROR3("[%s] `%s' : NOK (%s)", command->context->pos, command->context->command_line, error_to_string(errno, 0));\r
unit_set_error(command->unit, errno, 0, command->context->pos);\r
command_handle_failure(command, csr_dup2_function_failure);\r
}\r
unit_set_error(command->unit, errno, 0, command->context->pos);\r
command_handle_failure(command, csr_dup2_function_failure);\r
}\r
if(dup2(child_stdout_fd[1], STDERR_FILENO) < 0)\r
{\r
ERROR3("[%s] `%s' : NOK (%s)", command->context->pos, command->context->command_line, error_to_string(errno, 0));\r
unit_set_error(command->unit, errno, 0, command->context->pos);\r
command_handle_failure(command, csr_dup2_function_failure);\r
}\r
if(dup2(child_stdout_fd[1], STDERR_FILENO) < 0)\r
{\r
ERROR3("[%s] `%s' : NOK (%s)", command->context->pos, command->context->command_line, error_to_string(errno, 0));\r
unit_set_error(command->unit, errno, 0, command->context->pos);\r
command_handle_failure(command, csr_dup2_function_failure);\r
}\r
/* close the unused file descriptor */\r
close(child_stdout_fd[1]);\r
}\r
/* close the unused file descriptor */\r
close(child_stdout_fd[1]);\r
}\r
/* launch the command */\r
if(execlp("/bin/sh", "sh", "-c", command->context->command_line, NULL) < 0)\r
command->execlp_errno = errno;\r
/* launch the command */\r
if(execlp("/bin/sh", "sh", "-c", command->context->command_line, NULL) < 0)\r
command->execlp_errno = errno;\r
if(WAIT_FAILED == WaitForSingleObject(command->pid, INFINITE))\r
{\r
ERROR2("[%s] Cannot wait for the child`%s'", command->context->pos, command->context->command_line);\r
if(WAIT_FAILED == WaitForSingleObject(command->pid, INFINITE))\r
{\r
ERROR2("[%s] Cannot wait for the child`%s'", command->context->pos, command->context->command_line);\r
unit_set_error(command->unit, (int)GetLastError(), 0, command->context->pos);\r
\r
command_handle_failure(command, csr_wait_failure );\r
unit_set_error(command->unit, (int)GetLastError(), 0, command->context->pos);\r
\r
command_handle_failure(command, csr_wait_failure );\r
- /* TODO : see for the interruption */ \r
+ /* TODO : see for the interruption */\r
if(!GetExitCodeProcess(command->pid,&rv))\r
{\r
ERROR2("[%s] Cannot get the exit code of the process `%s'",command->context->pos, command->context->command_line);\r
if(!GetExitCodeProcess(command->pid,&rv))\r
{\r
ERROR2("[%s] Cannot get the exit code of the process `%s'",command->context->pos, command->context->command_line);\r
unit_set_error(command->unit, (int)GetLastError(), 0, command->context->pos);\r
\r
unit_set_error(command->unit, (int)GetLastError(), 0, command->context->pos);\r
\r
- command_handle_failure(command, csr_get_exit_code_process_function_failure ); \r
+ command_handle_failure(command, csr_get_exit_code_process_function_failure );\r
}\r
else\r
command->stat_val = command->exit_code = rv;\r
}\r
else\r
command->stat_val = command->exit_code = rv;\r
{\r
/* let this thread wait for the child so that the main thread can detect the timeout without blocking on the wait */\r
int pid = waitpid(command->pid, &(command->stat_val), 0);\r
{\r
/* let this thread wait for the child so that the main thread can detect the timeout without blocking on the wait */\r
int pid = waitpid(command->pid, &(command->stat_val), 0);\r
- \r
- if(pid != command->pid) \r
+\r
+ if(pid != command->pid)\r
{\r
ERROR2("[%s] Cannot wait for the child`%s'", command->context->pos, command->context->command_line);\r
\r
{\r
ERROR2("[%s] Cannot wait for the child`%s'", command->context->pos, command->context->command_line);\r
\r
{\r
int success = 1;\r
cs_reason_t reason;\r
{\r
int success = 1;\r
cs_reason_t reason;\r
/* we have a signal, store it */\r
if(WIFSIGNALED(command->stat_val))\r
{\r
command->signal = strdup(signal_name(WTERMSIG(command->stat_val),command->context->signal));\r
}\r
/* we have a signal, store it */\r
if(WIFSIGNALED(command->stat_val))\r
{\r
command->signal = strdup(signal_name(WTERMSIG(command->stat_val),command->context->signal));\r
}\r
/* we have a signal and no signal is expected */\r
/* we have a signal and no signal is expected */\r
- if(WIFSIGNALED(command->stat_val) && !command->context->signal) \r
+ if(WIFSIGNALED(command->stat_val) && !command->context->signal)\r
{\r
success = 0;\r
ERROR3("[%s] `%s' : NOK (unexpected signal `%s' caught)", command->context->pos, command->context->command_line, command->signal);\r
{\r
success = 0;\r
ERROR3("[%s] `%s' : NOK (unexpected signal `%s' caught)", command->context->pos, command->context->command_line, command->signal);\r
\r
reason = csr_unexpected_signal_caught;\r
}\r
\r
reason = csr_unexpected_signal_caught;\r
}\r
/* we have a signal that differ form the expected signal */\r
/* we have a signal that differ form the expected signal */\r
- if(WIFSIGNALED(command->stat_val) && command->context->signal && strcmp(signal_name(WTERMSIG(command->stat_val),command->context->signal),command->context->signal)) \r
+ if(WIFSIGNALED(command->stat_val) && command->context->signal && strcmp(signal_name(WTERMSIG(command->stat_val),command->context->signal),command->context->signal))\r
{\r
\r
ERROR4("[%s] `%s' : NOK (got signal `%s' instead of `%s')", command->context->pos, command->context->command_line, command->signal, command->context->signal);\r
{\r
\r
ERROR4("[%s] `%s' : NOK (got signal `%s' instead of `%s')", command->context->pos, command->context->command_line, command->signal, command->context->signal);\r
if(success)\r
{\r
success = 0;\r
unit_set_error(command->unit, ESIGNOTMATCH, 1, command->context->pos);\r
}\r
if(success)\r
{\r
success = 0;\r
unit_set_error(command->unit, ESIGNOTMATCH, 1, command->context->pos);\r
}\r
reason = csr_signals_dont_match;\r
}\r
reason = csr_signals_dont_match;\r
}\r
- \r
- /* we don't receipt the expected signal */\r
- if(!WIFSIGNALED(command->stat_val) && command->context->signal) \r
+\r
+ /* we don't receive the expected signal */\r
+ if(!WIFSIGNALED(command->stat_val) && command->context->signal)\r
- \r
- ERROR3("[%s] `%s' : NOK (expected `%s' not receipt)", command->context->pos, command->context->command_line, command->context->signal);\r
- \r
+\r
+ ERROR3("[%s] `%s' : NOK (expected `%s' not received)", command->context->pos, command->context->command_line, command->context->signal);\r
+\r
if(success)\r
{\r
success = 0;\r
if(success)\r
{\r
success = 0;\r
- unit_set_error(command->unit, ESIGNOTRECEIPT, 1, command->context->pos);\r
+ unit_set_error(command->unit, ESIGNOTRECEIVED, 1, command->context->pos);\r
- \r
- reason = csr_expected_signal_not_receipt;\r
+\r
+ reason = csr_expected_signal_not_received;\r
/* if the command exit normaly and we expect a exit code : test it */\r
if(WIFEXITED(command->stat_val) /* && INDEFINITE != command->context->exit_code*/)\r
{\r
/* if the command exit normaly and we expect a exit code : test it */\r
if(WIFEXITED(command->stat_val) /* && INDEFINITE != command->context->exit_code*/)\r
{\r
if(WEXITSTATUS(command->stat_val) != command->context->exit_code)\r
{\r
ERROR4("[%s] %s : NOK (returned code `%d' instead `%d')", command->context->pos, command->context->command_line, WEXITSTATUS(command->stat_val), command->context->exit_code);\r
if(WEXITSTATUS(command->stat_val) != command->context->exit_code)\r
{\r
ERROR4("[%s] %s : NOK (returned code `%d' instead `%d')", command->context->pos, command->context->command_line, WEXITSTATUS(command->stat_val), command->context->exit_code);\r
if(success)\r
{\r
success = 0;\r
unit_set_error(command->unit, EEXITCODENOTMATCH, 1, command->context->pos);\r
}\r
if(success)\r
{\r
success = 0;\r
unit_set_error(command->unit, EEXITCODENOTMATCH, 1, command->context->pos);\r
}\r
reason = csr_exit_codes_dont_match;\r
}\r
}\r
reason = csr_exit_codes_dont_match;\r
}\r
}\r
/* make sure the reader done */\r
while(!command->reader->done)\r
xbt_os_thread_yield();\r
/* make sure the reader done */\r
while(!command->reader->done)\r
xbt_os_thread_yield();\r
#ifdef WIN32\r
CloseHandle(command->stdout_fd);\r
#else\r
#ifdef WIN32\r
CloseHandle(command->stdout_fd);\r
#else\r
char *out = xbt_str_join(a,"\n||");\r
xbt_dynar_free(&a);\r
INFO2("Output of <%s> so far: \n||%s", command->context->pos,out);\r
char *out = xbt_str_join(a,"\n||");\r
xbt_dynar_free(&a);\r
INFO2("Output of <%s> so far: \n||%s", command->context->pos,out);\r
}\r
/* if ouput handling flag is specified check the output */\r
else if(oh_check == command->context->output_handling && command->reader)\r
}\r
/* if ouput handling flag is specified check the output */\r
else if(oh_check == command->context->output_handling && command->reader)\r
ERROR2("[%s] `%s' : NOK (outputs mismatch):", command->context->pos, command->context->command_line);\r
ERROR2("[%s] `%s' : NOK (outputs mismatch):", command->context->pos, command->context->command_line);\r
if(success)\r
{\r
unit_set_error(command->unit, EOUTPUTNOTMATCH, 1, command->context->pos);\r
if(success)\r
{\r
unit_set_error(command->unit, EOUTPUTNOTMATCH, 1, command->context->pos);\r
reason = csr_outputs_dont_match;\r
\r
/* display the diff */\r
reason = csr_outputs_dont_match;\r
\r
/* display the diff */\r
- diff = xbt_str_diff(command->context->output->data,command->output->data); \r
+ diff = xbt_str_diff(command->context->output->data,command->output->data);\r
INFO1("%s",diff);\r
free(diff);\r
}\r
}\r
INFO1("%s",diff);\r
free(diff);\r
}\r
}\r
- else if (oh_ignore == command->context->output_handling) \r
+ else if (oh_ignore == command->context->output_handling)\r
{\r
INFO1("(ignoring the output of <%s> as requested)",command->context->line);\r
{\r
INFO1("(ignoring the output of <%s> as requested)",command->context->line);\r
- } \r
- else if (oh_display == command->context->output_handling) \r
+ }\r
+ else if (oh_display == command->context->output_handling)\r
{\r
xbt_dynar_t a = xbt_str_split(command->output->data, "\n");\r
char *out = xbt_str_join(a,"\n||");\r
xbt_dynar_free(&a);\r
INFO3("[%s] Here is the (ignored) command `%s' output: \n||%s",command->context->pos, command->context->command_line, out);\r
free(out);\r
{\r
xbt_dynar_t a = xbt_str_split(command->output->data, "\n");\r
char *out = xbt_str_join(a,"\n||");\r
xbt_dynar_free(&a);\r
INFO3("[%s] Here is the (ignored) command `%s' output: \n||%s",command->context->pos, command->context->command_line, out);\r
free(out);\r
if(success)\r
{\r
xbt_os_mutex_acquire(command->mutex);\r
if(success)\r
{\r
xbt_os_mutex_acquire(command->mutex);\r
if(command->status != cs_interrupted)\r
{\r
/* signal the success of the command */\r
if(command->status != cs_interrupted)\r
{\r
/* signal the success of the command */\r
/* increment the number of successeded command of the unit */\r
(command->root->successeded_cmd_nb)++;\r
}\r
/* increment the number of successeded command of the unit */\r
(command->root->successeded_cmd_nb)++;\r
}\r
- \r
- xbt_os_mutex_release(command->mutex); \r
+\r
+ xbt_os_mutex_release(command->mutex);\r
if(INDEFINITE_PID != command->pid)\r
{\r
kill(command->pid,SIGTERM);\r
if(INDEFINITE_PID != command->pid)\r
{\r
kill(command->pid,SIGTERM);\r
if(!command->context->signal)\r
command->context->signal = strdup("SIGTERM");\r
if(!command->context->signal)\r
command->context->signal = strdup("SIGTERM");\r
command->exit_code = INDEFINITE;\r
command->killed = 1;\r
command->exit_code = INDEFINITE;\r
command->killed = 1;\r
usleep(100);\r
\r
INFO2("[%s] Kill the process `%s'", command->context->pos, command->context->command_line);\r
usleep(100);\r
\r
INFO2("[%s] Kill the process `%s'", command->context->pos, command->context->command_line);\r
- kill(command->pid,SIGKILL); \r
+ kill(command->pid,SIGKILL);\r
+\r
command_interrupt(command_t command)\r
{\r
xbt_os_mutex_acquire(command->mutex);\r
command_interrupt(command_t command)\r
{\r
xbt_os_mutex_acquire(command->mutex);\r
if((command->status != cs_interrupted) && (command->status != cs_failed) && (command->status != cs_successeded))\r
{\r
if((command->status != cs_interrupted) && (command->status != cs_failed) && (command->status != cs_successeded))\r
{\r
- command->status = cs_interrupted; \r
+ command->status = cs_interrupted;\r
command->reason = csr_interruption_request;\r
command->interrupted = 1;\r
command->unit->interrupted = 1;\r
command->reason = csr_interruption_request;\r
command->interrupted = 1;\r
command->unit->interrupted = 1;\r
xbt_os_mutex_acquire(command->root->mutex);\r
(command->root->interrupted_cmd_nb)++;\r
xbt_os_mutex_release(command->root->mutex);\r
xbt_os_mutex_acquire(command->root->mutex);\r
(command->root->interrupted_cmd_nb)++;\r
xbt_os_mutex_release(command->root->mutex);\r
if(command->pid != INDEFINITE_PID)\r
command_kill(command);\r
}\r
if(command->pid != INDEFINITE_PID)\r
command_kill(command);\r
}\r
xbt_os_mutex_release(command->mutex);\r
xbt_os_mutex_release(command->mutex);\r
{\r
if(cs_successeded != command->status)\r
{\r
{\r
if(cs_successeded != command->status)\r
{\r
#ifndef WIN32\r
if(command->killed)\r
printf(" <killed command>\n");\r
#endif\r
#ifndef WIN32\r
if(command->killed)\r
printf(" <killed command>\n");\r
#endif\r
/* display the reason of the status of the command */\r
switch(command->reason)\r
{\r
/* display the reason of the status of the command */\r
switch(command->reason)\r
{\r
case csr_pipe_function_failed :\r
printf(" reason : pipe() or CreatePipe() function failed (system error)\n");\r
break;\r
case csr_pipe_function_failed :\r
printf(" reason : pipe() or CreatePipe() function failed (system error)\n");\r
break;\r
case csr_shell_failed :\r
printf(" reason : shell failed (may be command not found)\n");\r
break;\r
case csr_shell_failed :\r
printf(" reason : shell failed (may be command not found)\n");\r
break;\r
case csr_get_exit_code_process_function_failure :\r
printf(" reason : ExitCodeProcess() function failed (system error)\n");\r
break;\r
case csr_get_exit_code_process_function_failure :\r
printf(" reason : ExitCodeProcess() function failed (system error)\n");\r
break;\r
/* reader failure reasons*/\r
case csr_read_pipe_broken :\r
printf(" reason : command read pipe broken\n");\r
/* reader failure reasons*/\r
case csr_read_pipe_broken :\r
printf(" reason : command read pipe broken\n");\r
case csr_read_failure :\r
printf(" reason : command stdout read failed\n");\r
break;\r
case csr_read_failure :\r
printf(" reason : command stdout read failed\n");\r
break;\r
/* writer failure reasons */\r
case csr_write_failure :\r
printf(" reason : command stdin write failed\n");\r
/* writer failure reasons */\r
case csr_write_failure :\r
printf(" reason : command stdin write failed\n");\r
case csr_write_pipe_broken :\r
printf(" reason : command write pipe broken\n");\r
break;\r
case csr_write_pipe_broken :\r
printf(" reason : command write pipe broken\n");\r
break;\r
/* timer reason */\r
case csr_timeout :\r
printf(" reason : command timeouted\n");\r
break;\r
/* timer reason */\r
case csr_timeout :\r
printf(" reason : command timeouted\n");\r
break;\r
/* command failure reason */\r
case csr_command_not_found :\r
printf(" reason : command not found\n");\r
break;\r
/* command failure reason */\r
case csr_command_not_found :\r
printf(" reason : command not found\n");\r
break;\r
/* context failure reasons */\r
case csr_exit_codes_dont_match :\r
printf(" reason : exit codes don't match\n");\r
/* context failure reasons */\r
case csr_exit_codes_dont_match :\r
printf(" reason : exit codes don't match\n");\r
/* dup2 function failure reasons */\r
case csr_dup2_function_failure :\r
printf(" reason : dup2() function failed\n");\r
/* dup2 function failure reasons */\r
case csr_dup2_function_failure :\r
printf(" reason : dup2() function failed\n");\r
/* execlp function failure reasons */\r
case csr_execlp_function_failure :\r
printf(" reason : execlp() function failed\n");\r
/* execlp function failure reasons */\r
case csr_execlp_function_failure :\r
printf(" reason : execlp() function failed\n");\r
/* waitpid function failure reasons */\r
case csr_waitpid_function_failure :\r
printf(" reason : waitpid() function failed\n");\r
/* waitpid function failure reasons */\r
case csr_waitpid_function_failure :\r
printf(" reason : waitpid() function failed\n");\r
/* CreateProcess function failure reasons */\r
case csr_create_process_function_failure :\r
printf(" reason : CreateProcesss() function failed\n");\r
/* CreateProcess function failure reasons */\r
case csr_create_process_function_failure :\r
printf(" reason : CreateProcesss() function failed\n");\r
case csr_outputs_dont_match :\r
{\r
/*char *diff;*/\r
printf(" reason : ouputs don't match\n");\r
case csr_outputs_dont_match :\r
{\r
/*char *diff;*/\r
printf(" reason : ouputs don't match\n");\r
- /*diff = xbt_str_diff(command->context->output->data,command->output->data); \r
+ /*diff = xbt_str_diff(command->context->output->data,command->output->data);\r
printf(" output diff :\n%s\n",diff);\r
free(diff);*/\r
printf(" output diff :\n%s\n",diff);\r
free(diff);*/\r
\r
break;\r
\r
case csr_signals_dont_match :\r
\r
break;\r
\r
case csr_signals_dont_match :\r
- printf(" reason : signals don't match\n"); \r
+ printf(" reason : signals don't match\n");\r
case csr_unexpected_signal_caught:\r
printf(" reason : unexpected signal caught\n");\r
break;\r
case csr_unexpected_signal_caught:\r
printf(" reason : unexpected signal caught\n");\r
break;\r
- \r
- case csr_expected_signal_not_receipt :\r
+\r
+ case csr_expected_signal_not_received :\r
printf(" reason : expected signal not receipt\n");\r
break;\r
\r
printf(" reason : expected signal not receipt\n");\r
break;\r
\r
case csr_fork_function_failure :\r
printf(" reason : fork function failed\n");\r
break;\r
case csr_fork_function_failure :\r
printf(" reason : fork function failed\n");\r
break;\r
case csr_wait_failure :\r
printf(" reason : wait command failure\n");\r
break;\r
case csr_wait_failure :\r
printf(" reason : wait command failure\n");\r
break;\r
/* global/local interruption */\r
case csr_interruption_request :\r
printf(" reason : the command receive a interruption request\n");\r
break;\r
/* global/local interruption */\r
case csr_interruption_request :\r
printf(" reason : the command receive a interruption request\n");\r
break;\r
/* unknown ? */\r
case csr_unknown :\r
printf(" reason : unknown \n");\r
/* unknown ? */\r
case csr_unknown :\r
printf(" reason : unknown \n");\r
if(INDEFINITE != command->exit_code)\r
/* the command exit code */\r
printf(" exit code : %d\n",command->exit_code);\r
if(INDEFINITE != command->exit_code)\r
/* the command exit code */\r
printf(" exit code : %d\n",command->exit_code);\r
/* if an expected exit code was specified display it */\r
if(INDEFINITE != command->context->exit_code)\r
printf(" expected exit code : %d\n",command->context->exit_code);\r
else\r
printf(" no expected exit code specified\n");\r
/* if an expected exit code was specified display it */\r
if(INDEFINITE != command->context->exit_code)\r
printf(" expected exit code : %d\n",command->context->exit_code);\r
else\r
printf(" no expected exit code specified\n");\r
/* no expected signal expected */\r
if(NULL == command->context->signal)\r
{\r
/* no expected signal expected */\r
if(NULL == command->context->signal)\r
{\r
\r
if(command->signal)\r
printf(" but got signal : %s\n",command->signal);\r
\r
if(command->signal)\r
printf(" but got signal : %s\n",command->signal);\r
}\r
/* if an expected exit code was specified display it */\r
else\r
}\r
/* if an expected exit code was specified display it */\r
else\r
else\r
printf(" no signal caugth\n");\r
}\r
else\r
printf(" no signal caugth\n");\r
}\r
/* if the command has out put and the metacommand display output is specified display it */\r
if(command->output && (0 != command->output->used) && (oh_display == command->context->output_handling))\r
{\r
/* if the command has out put and the metacommand display output is specified display it */\r
if(command->output && (0 != command->output->used) && (oh_display == command->context->output_handling))\r
{\r
command_handle_failure(command_t command, cs_reason_t reason)\r
{\r
unit_t root = command->root;\r
command_handle_failure(command_t command, cs_reason_t reason)\r
{\r
unit_t root = command->root;\r
xbt_os_mutex_acquire(command->mutex);\r
\r
if((command->status != cs_interrupted) && (command->status != cs_failed))\r
xbt_os_mutex_acquire(command->mutex);\r
\r
if((command->status != cs_interrupted) && (command->status != cs_failed))\r
command->failed = 1;\r
\r
command->unit->failed = 1;\r
command->failed = 1;\r
\r
command->unit->failed = 1;\r
xbt_os_mutex_acquire(root->mutex);\r
xbt_os_mutex_acquire(root->mutex);\r
/* increment the number of failed command of the unit */\r
root->failed_cmd_nb++;\r
/* increment the number of failed command of the unit */\r
root->failed_cmd_nb++;\r
/* if the --ignore-failures option is not specified */\r
if(!keep_going_unit_flag)\r
{\r
/* if the --ignore-failures option is not specified */\r
if(!keep_going_unit_flag)\r
{\r
/* release the unit */\r
xbt_os_sem_release(root->sem);\r
}\r
/* release the unit */\r
xbt_os_sem_release(root->sem);\r
}\r
/* if the --keep-going option is not specified */\r
if(!keep_going_flag)\r
{\r
/* if the --keep-going option is not specified */\r
if(!keep_going_flag)\r
{\r
{\r
/* request an global interruption by the runner */\r
interrupted = 1;\r
{\r
/* request an global interruption by the runner */\r
interrupted = 1;\r
/* release the runner */\r
xbt_os_sem_release(units_sem);\r
}\r
/* release the runner */\r
xbt_os_sem_release(units_sem);\r
}\r
#ifdef WIN32\r
if((*ptr)->stdin_fd != INDEFINITE_FD)\r
CloseHandle((*ptr)->stdin_fd);\r
#ifdef WIN32\r
if((*ptr)->stdin_fd != INDEFINITE_FD)\r
CloseHandle((*ptr)->stdin_fd);\r
if((*ptr)->stdout_fd != INDEFINITE_FD)\r
CloseHandle((*ptr)->stdout_fd);\r
if((*ptr)->stdout_fd != INDEFINITE_FD)\r
CloseHandle((*ptr)->stdout_fd);\r
if((*ptr)->stdin_fd != INDEFINITE_FD)\r
close((*ptr)->stdin_fd);\r
if((*ptr)->stdin_fd != INDEFINITE_FD)\r
close((*ptr)->stdin_fd);\r
- \r
- if((*ptr)->stdout_fd != INDEFINITE_FD) \r
+\r
+ if((*ptr)->stdout_fd != INDEFINITE_FD)\r
close((*ptr)->stdout_fd);\r
#endif\r
close((*ptr)->stdout_fd);\r
#endif\r
if((*ptr)->timer)\r
{\r
if(timer_free(&((*ptr)->timer)) < 0)\r
return -1;\r
}\r
if((*ptr)->timer)\r
{\r
if(timer_free(&((*ptr)->timer)) < 0)\r
return -1;\r
}\r
if((*ptr)->writer)\r
{\r
if(writer_free(&((*ptr)->writer)) < 0)\r
return -1;\r
}\r
if((*ptr)->writer)\r
{\r
if(writer_free(&((*ptr)->writer)) < 0)\r
return -1;\r
}\r
if((*ptr)->reader)\r
{\r
if(reader_free(&((*ptr)->reader)) < 0)\r
return -1;\r
}\r
if((*ptr)->reader)\r
{\r
if(reader_free(&((*ptr)->reader)) < 0)\r
return -1;\r
}\r
if((*ptr)->output)\r
xbt_strbuff_free((*ptr)->output);\r
if((*ptr)->output)\r
xbt_strbuff_free((*ptr)->output);\r
if((*ptr)->context)\r
{\r
if(context_free(&((*ptr)->context)) < 0)\r
if((*ptr)->context)\r
{\r
if(context_free(&((*ptr)->context)) < 0)\r
free((*ptr)->signal);\r
\r
free(*ptr);\r
free((*ptr)->signal);\r
\r
free(*ptr);\r
size_t pos, i;\r
char* begin;\r
char* buf;\r
size_t pos, i;\r
char* begin;\r
char* buf;\r
if(!(begin = strstr(*str, what)))\r
{\r
errno = ESRCH;\r
return -1;\r
}\r
if(!(begin = strstr(*str, what)))\r
{\r
errno = ESRCH;\r
return -1;\r
}\r
if(begin == *str)\r
{\r
if(!(buf = (char*) calloc(strlen(with) + ((pos < strlen(*str)) ? strlen(*str + pos) : 0) + 1, sizeof(char))))\r
return -1;\r
if(begin == *str)\r
{\r
if(!(buf = (char*) calloc(strlen(with) + ((pos < strlen(*str)) ? strlen(*str + pos) : 0) + 1, sizeof(char))))\r
return -1;\r
if(pos < strlen(*str))\r
strcpy(buf + strlen(with), *str + pos);\r
}\r
if(pos < strlen(*str))\r
strcpy(buf + strlen(with), *str + pos);\r
}\r
{\r
if(!(buf = (char*) calloc((begin - *str) + strlen(with) + ((pos < strlen(*str)) ? strlen(*str + pos) : 0) + 1, sizeof(char))))\r
return -1;\r
{\r
if(!(buf = (char*) calloc((begin - *str) + strlen(with) + ((pos < strlen(*str)) ? strlen(*str + pos) : 0) + 1, sizeof(char))))\r
return -1;\r
strncpy(buf, *str, (begin - *str));\r
strcpy(buf + (begin - *str) , with);\r
strncpy(buf, *str, (begin - *str));\r
strcpy(buf + (begin - *str) , with);\r
\r
if(pos < strlen(*str))\r
strcpy(buf + (begin - *str) + strlen(with), *str + pos);\r
\r
if(pos < strlen(*str))\r
strcpy(buf + (begin - *str) + strlen(with), *str + pos);\r
free(*str);;\r
*str = buf;\r
free(*str);;\r
*str = buf;\r
*/\r
\r
/* last version int\r
*/\r
\r
/* last version int\r
if(!(delimited = (char*) calloc((strlen(what) + 2) , sizeof(char))))\r
return -1;\r
\r
if(!(delimited = (char*) calloc((strlen(what) + 2) , sizeof(char))))\r
return -1;\r
\r
memset(delimited, 0, (strlen(what) + 2));\r
\r
sprintf(delimited,"%s%c", what, delimiters[i]);\r
memset(delimited, 0, (strlen(what) + 2));\r
\r
sprintf(delimited,"%s%c", what, delimiters[i]);\r
if((begin = strstr(*str, delimited)))\r
break;\r
}\r
if((begin = strstr(*str, delimited)))\r
break;\r
}\r
if(!begin && (size = (int)strlen(*str) - (int)strlen(what)) >= 0 && !strcmp(*str + size, what))\r
begin = strstr(*str, what);\r
if(!begin && (size = (int)strlen(*str) - (int)strlen(what)) >= 0 && !strcmp(*str + size, what))\r
begin = strstr(*str, what);\r
if(!begin)\r
{\r
errno = ESRCH;\r
return -1;\r
}\r
if(!begin)\r
{\r
errno = ESRCH;\r
return -1;\r
}\r
pos += strlen(what);\r
\r
if(begin == *str)\r
{\r
pos += strlen(what);\r
\r
if(begin == *str)\r
{\r
\r
if(!(buf = (char*) calloc(strlen(with) + ((pos < strlen(*str)) ? strlen(*str + pos) : 0) + 1, sizeof(char))))\r
return -1;\r
\r
if(!(buf = (char*) calloc(strlen(with) + ((pos < strlen(*str)) ? strlen(*str + pos) : 0) + 1, sizeof(char))))\r
return -1;\r
if(pos < strlen(*str))\r
strcpy(buf + strlen(with), *str + pos);\r
}\r
if(pos < strlen(*str))\r
strcpy(buf + strlen(with), *str + pos);\r
}\r
{\r
if(!(buf = (char*) calloc((begin - *str) + strlen(with) + ((pos < strlen(*str)) ? strlen(*str + pos) : 0) + 1, sizeof(char))))\r
return -1;\r
{\r
if(!(buf = (char*) calloc((begin - *str) + strlen(with) + ((pos < strlen(*str)) ? strlen(*str + pos) : 0) + 1, sizeof(char))))\r
return -1;\r
strncpy(buf, *str, (begin - *str));\r
strcpy(buf + (begin - *str) , with);\r
\r
if(pos < strlen(*str))\r
strcpy(buf + (begin - *str) + strlen(with), *str + pos);\r
strncpy(buf, *str, (begin - *str));\r
strcpy(buf + (begin - *str) , with);\r
\r
if(pos < strlen(*str))\r
strcpy(buf + (begin - *str) + strlen(with), *str + pos);\r
free(*str);;\r
*str = buf;\r
free(*str);;\r
*str = buf;\r
}*/\r
\r
int\r
str_replace(char** str, const char* what, const char* with, const char* delimiters)\r
{\r
size_t pos, i, len;\r
}*/\r
\r
int\r
str_replace(char** str, const char* what, const char* with, const char* delimiters)\r
{\r
size_t pos, i, len;\r
char* buf;\r
int size;\r
\r
char* buf;\r
int size;\r
\r
memset(delimited, 0, (strlen(what) + 2));\r
\r
sprintf(delimited,"%s%c", what, delimiters[i]);\r
memset(delimited, 0, (strlen(what) + 2));\r
\r
sprintf(delimited,"%s%c", what, delimiters[i]);\r
if((begin = strstr(*str, delimited)))\r
break;\r
}\r
if((begin = strstr(*str, delimited)))\r
break;\r
}\r
free(delimited);\r
}\r
else\r
begin = strstr(*str, what);\r
free(delimited);\r
}\r
else\r
begin = strstr(*str, what);\r
if(!begin && (size = (int)strlen(*str) - (int)strlen(what)) >= 0 && !strcmp(*str + size, what))\r
begin = strstr(*str, what);\r
if(!begin && (size = (int)strlen(*str) - (int)strlen(what)) >= 0 && !strcmp(*str + size, what))\r
begin = strstr(*str, what);\r
if(!begin)\r
{\r
errno = ESRCH;\r
return -1;\r
}\r
if(!begin)\r
{\r
errno = ESRCH;\r
return -1;\r
}\r
pos += strlen(what);\r
\r
if(begin == *str)\r
{\r
if(!(buf = (char*) calloc((with ? strlen(with) : 0) + ((pos < strlen(*str)) ? strlen(*str + pos) : 0) + 1, sizeof(char))))\r
return -1;\r
pos += strlen(what);\r
\r
if(begin == *str)\r
{\r
if(!(buf = (char*) calloc((with ? strlen(with) : 0) + ((pos < strlen(*str)) ? strlen(*str + pos) : 0) + 1, sizeof(char))))\r
return -1;\r
if(with)\r
strcpy(buf, with);\r
if(with)\r
strcpy(buf, with);\r
if(pos < strlen(*str))\r
strcpy(buf + (with ? strlen(with) : 0), *str + pos);\r
}\r
if(pos < strlen(*str))\r
strcpy(buf + (with ? strlen(with) : 0), *str + pos);\r
}\r
{\r
if(!(buf = (char*) calloc((begin - *str) + (with ? strlen(with) : 0) + ((pos < strlen(*str)) ? strlen(*str + pos) : 0) + 1, sizeof(char))))\r
return -1;\r
{\r
if(!(buf = (char*) calloc((begin - *str) + (with ? strlen(with) : 0) + ((pos < strlen(*str)) ? strlen(*str + pos) : 0) + 1, sizeof(char))))\r
return -1;\r
strncpy(buf, *str, (begin - *str));\r
strncpy(buf, *str, (begin - *str));\r
if(with)\r
strcpy(buf + (begin - *str) , with);\r
\r
if(pos < strlen(*str))\r
strcpy(buf + (begin - *str) + (with ? strlen(with) : 0), *str + pos);\r
if(with)\r
strcpy(buf + (begin - *str) , with);\r
\r
if(pos < strlen(*str))\r
strcpy(buf + (begin - *str) + (with ? strlen(with) : 0), *str + pos);\r
free(*str);\r
\r
*str = buf;\r
free(*str);\r
\r
*str = buf;\r
\r
int\r
str_replace_all(char** str, const char* what, const char* with, const char* delimiters)\r
{\r
int rv;\r
\r
int\r
str_replace_all(char** str, const char* what, const char* with, const char* delimiters)\r
{\r
int rv;\r
while(!(rv = str_replace(str, what, with, delimiters)));\r
while(!(rv = str_replace(str, what, with, delimiters)));\r
return (errno == ESRCH) ? 0 : -1;\r
}\r
\r
return (errno == ESRCH) ? 0 : -1;\r
}\r
\r
str_replace_all(char** str, const char* what, const char* with)\r
{\r
int rv;\r
str_replace_all(char** str, const char* what, const char* with)\r
{\r
int rv;\r
while(!(rv = str_replace(str, what, with)));\r
while(!(rv = str_replace(str, what, with)));\r
return (errno == ESRCH) ? 0 : -1;\r
}*/\r
\r
return (errno == ESRCH) ? 0 : -1;\r
}*/\r
\r
\r
{"EUNXPSIG", EUNXPSIG,1, "unexpected signal caught"},\r
\r
\r
{"EUNXPSIG", EUNXPSIG,1, "unexpected signal caught"},\r
\r
- {"ESIGNOTRECEIPT", ESIGNOTRECEIPT,1, "expected signal not receipt"},\r
+ {"ESIGNOTRECEIPT", ESIGNOTRECEIVED,1, "expected signal not receipt"},\r
\r
{"EPROCCMDLINE", EPROCCMDLINE, 1, "command line processing failed"},\r
\r
\r
{"EPROCCMDLINE", EPROCCMDLINE, 1, "command line processing failed"},\r
\r