Fri 13 Jun 2014 09:24:16 AM UTC, original submission:
See also this thead: http://octave.1599824.n4.nabble.com/mkoctfile-exits-with-0-if-gcc-failed-td4664462.html and http://octave.1599824.n4.nabble.com/RE-return-code-of-mkoctfile-td4664466.html
mkoctfile returns 0 if the called subprocess returns != 0.
This is because system returns the exit status of the called process in the upper 8bits. According to "man wait" WIFEXITED and WEXITSTSTUS should be used for the bit shifting and masking stuff.
I propose the following patch (hg changeset attached):
diff -r 0ede4dbb37f1 src/mkoctfile.in.cc
--- a/src/mkoctfile.in.cc Sun Mar 30 14:18:43 2014 -0700
+++ b/src/mkoctfile.in.cc Wed Jun 04 14:42:58 2014 +0200
@@ -344,7 +344,10 @@
{
if (debug)
std::cout << cmd << std::endl;
- return system (cmd.c_str ());
+ int result = system (cmd.c_str ());
+ if (WIFEXITED (result))
+ result = WEXITSTATUS (result);
+ return result;
}
If I use the makros WIFEXITED and WEXITSTATUS I get these warnings when compiling mkoctfile on debian wheezy 64bit with gcc 4.7.2:
The old style cast is defined in /usr/include/stdlib.h:55
Perhaps we should use the octave wrappers like in toplev.cc:
There are also some other definitions of these makros which wouldn't trigger teh old-style warning:
I'll attach a patch using WIFEXITED and WEXITSTATUS (ignoring the old-style cast warning)
-- Andy
|