Cezar Andrei has proposed merging lp:~zorba-coders/zorba/bug1086323-processExitCode into lp:zorba/process-module.
Requested reviews: Sorin Marian Nasoi (sorin.marian.nasoi) Paul J. Lucas (paul-lucas) Chris Hillery (ceejatec) Related bugs: Bug #1086323 in Zorba: "Process module: exit code reporting is broken" https://bugs.launchpad.net/zorba/+bug/1086323 For more details, see: https://code.launchpad.net/~zorba-coders/zorba/bug1086323-processExitCode/+merge/138266 Fix for bug 1086323. -- https://code.launchpad.net/~zorba-coders/zorba/bug1086323-processExitCode/+merge/138266 Your team Zorba Coders is subscribed to branch lp:zorba/process-module.
=== modified file 'src/com/zorba-xquery/www/modules/process.xq' --- src/com/zorba-xquery/www/modules/process.xq 2012-09-27 16:53:40 +0000 +++ src/com/zorba-xquery/www/modules/process.xq 2012-12-05 17:32:30 +0000 @@ -56,6 +56,11 @@ : @return the result of the execution as an element as : shown in the documentation of this module. The exit-code : element returns the exit code of the child process. + : For POSIX compliant platforms: returns the process exit code. If process is + : terminated: (-1000) - termination signal code. If process is stoped: + : (-2000) - stop signal code or -1999 othewise. + : For Windows platforms: returns the return value of the process or the exit + : or terminate process specified value. : : @error process:PROC01 if an error occurred while communicating : with the executed process. @@ -75,6 +80,11 @@ : @return the result of the execution as an element as : shown in the documentation of this module. The exit-code : element returns the exit code of the child process. + : For POSIX compliant platforms: returns the process exit code. If process is + : terminated: (-1000) - termination signal code. If process is stoped: + : (-2000) - stop signal code or -1999 othewise. + : For Windows platforms: returns the return value of the process or the exit + : or terminate process specified value. : : @error process:PROC01 if an error occurred while communicating : with the executed process. === modified file 'src/com/zorba-xquery/www/modules/process.xq.src/process.cpp' --- src/com/zorba-xquery/www/modules/process.xq.src/process.cpp 2012-07-21 01:09:37 +0000 +++ src/com/zorba-xquery/www/modules/process.xq.src/process.cpp 2012-12-05 17:32:30 +0000 @@ -257,7 +257,7 @@ }; //start child process - BOOL ok=create_child_process(lStdOut,lStdErr,aCommand,lChildProcessInfo); + BOOL ok = create_child_process(lStdOut,lStdErr,aCommand,lChildProcessInfo); if(ok==TRUE) { @@ -413,8 +413,8 @@ std::ostringstream lStderr; #ifdef WIN32 - std::string lCommandLineString=lTmp.str(); - int code = run_process(lCommandLineString,lStdout,lStderr); + std::string lCommandLineString = lTmp.str(); + int code = run_process(lCommandLineString, lStdout, lStderr); if (code != 0) { @@ -424,6 +424,7 @@ "http://www.zorba-xquery.com/modules/process", "PROC01"); throw USER_EXCEPTION(lQName, lErrorMsg.str().c_str()); } + exit_code = code; #else //not WIN32 @@ -470,36 +471,39 @@ int stat = 0; - waitpid(pid, &stat, 0); - /*pid_t w; - do - { - w = waitpid(pid, &stat, WUNTRACED | WCONTINUED); - if (w == -1) - { - perror("waitpid"); - exit(EXIT_FAILURE); - } + pid_t w = waitpid(pid, &stat, 0); + + if (w == -1) + { + std::stringstream lErrorMsg; + lErrorMsg << "Failed to wait for child process "; + Item lQName = ProcessModule::getItemFactory()->createQName( + "http://www.zorba-xquery.com/modules/process", "PROC01"); + throw USER_EXCEPTION(lQName, lErrorMsg.str().c_str()); + } - if (WIFEXITED(stat)) - { - printf("exited, status=%d\n", WEXITSTATUS(stat)); - } - else if (WIFSIGNALED(stat)) - { - printf("killed by signal %d\n", WTERMSIG(stat)); - } - else if (WIFSTOPPED(stat)) - { - printf("stopped by signal %d\n", WSTOPSIG(stat)); - } - else if (WIFCONTINUED(stat)) - { - printf("continued\n"); - } - } while (!WIFEXITED(stat) && !WIFSIGNALED(stat)); - */ - exit_code = WEXITSTATUS(stat); + if (WIFEXITED(stat)) + { + //std::cout << " WEXITSTATUS : " << WEXITSTATUS(stat) << std::endl; std::cout.flush(); + exit_code = WEXITSTATUS(stat); + } + else if (WIFSIGNALED(stat)) + { + //std::cout << " WTERMSIG : " << WTERMSIG(stat) << std::endl; std::cout.flush(); + exit_code = 128 + WTERMSIG(stat); + } + else if (WIFSTOPPED(stat)) + { + //std::cout << " STOPSIG : " << WSTOPSIG(stat) << std::endl; std::cout.flush(); + exit_code = 128 + WSTOPSIG(stat); + } + else + { + //std::cout << " else : " << std::endl; std::cout.flush(); + exit_code = 255; + } + + //std::cout << " exit_code : " << exit_code << std::endl; std::cout.flush(); } #endif // WIN32
-- Mailing list: https://launchpad.net/~zorba-coders Post to : zorba-coders@lists.launchpad.net Unsubscribe : https://launchpad.net/~zorba-coders More help : https://help.launchpad.net/ListHelp