Commit ab30c8b6 authored by József Gyürüsi's avatar József Gyürüsi
Browse files

[internal #0] error handling fix in f_EPTF_Base_executeShell



Change-Id: I83dae287d88195253cb947c58c331d7a1d39e689
Signed-off-by: József Gyürüsi's avatarJózsef Gyürüsi <jozsef.gyurusi@ericsson.com>
parent ecee6bb3
......@@ -209,7 +209,8 @@ INTEGER EPTF__CLL__Base__Functions::f__EPTF__Base__executeShell(const CHARSTRING
// execute
if(execvp(argv[0],argv) < 0) {
fprintf(stderr,"f_EPTF_Base_executeShell: Failed to start the %s",(const char*)argv[0]);
// failed to start the command with bash
// do not print anything to stderr here! Command may be successful with starting it with tcsh or sh
fflush(stdout);
fflush(stderr);
}
......@@ -219,7 +220,8 @@ INTEGER EPTF__CLL__Base__Functions::f__EPTF__Base__executeShell(const CHARSTRING
// execute
if(execvp(argv[0],argv) < 0) {
fprintf(stderr,"f_EPTF_Base_executeShell: Failed to start the %s",(const char*)argv[0]);
// failed to start the command with tcsh
// do not print anything to stderr here! Command may be successful with starting it with sh
fflush(stdout);
fflush(stderr);
}
......@@ -229,12 +231,27 @@ INTEGER EPTF__CLL__Base__Functions::f__EPTF__Base__executeShell(const CHARSTRING
// execute
if(execvp(argv[0],argv) < 0) {
// failed to start the command with sh
// do not print anything to stderr here! Error is printed below.
fflush(stdout);
fflush(stderr);
}
// generate error exit code with the false command (do not just call exit(1): it will close the used file descriptors which will also be closed on main thread)
// print error message here:
fprintf(stderr,"f_EPTF_Base_executeShell: Failed to start the command %s",(const char*)cmd);
fflush(stderr);
argv[0]="false";
argv[1]=NULL;
if(execvp(argv[0],argv)< 0) {
// this should be never reached
// if reached, there will be file descriptor closing errors and program may hang!
fprintf(stderr,"f_EPTF_Base_executeShell: Failed to start the %s",(const char*)argv[0]);
fflush(stdout);
fflush(stderr);
}
TTCN_Logger::log(TTCN_Logger::TTCN_DEBUG,"EXECVP FINISHED:");
// this is never reached: 2nd execvp is always successful
// this is never reached: last execvp is always successful
exit(1); // exit the child thread
} else { // Parent process
TTCN_Logger::log(TTCN_Logger::TTCN_DEBUG,"f_EPTF_Base_executeShell: %s launched with PID: %i",(const char*)pl__command, processPid);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment