Tim said:
You're still not adjusting the value of $? to get the actual
return code from the ``/system() calls. Again, $? contains more
than just the simple value after the "return" keyword of your
C program!
No it doesn't. Where's the "output is ..." information the
if/else structure following the backtick operation?
This code is still not a standalone piece of code which other
people may run to see the output you describe. The code you
provide, in addition to being incomplete, cannot produce the
exact output you describe below.
You have not *once* told us what the value of $cmd is, so we can
hardly reproduce this.
This is simply not true. You have never once, in any code
you've posted here, check that the return value of the external
program was 0. You have only checked that the value of $? is 0.
This is *not* the same thing.
Please respond with actual *full* code which demonstrates the
behavior, according to the posting guidelines. Please post code
that makes correct use of the $? variable. Please post code
that doesn't use the return value of one function to determine
the success of a different function.
Tim Hammerquist
Tim,
I cannot paste the code for $cmd program cause it is confidential and
it links with lots of other libraries in my project.
I modified my perl script to print the exit code as :
$do = `$cmd`;
print 'ec = ', $? >> 8, "\n";
$rc = system($cmd);
print 'ec = ', $? >> 8, "\n";
the first print statement at time gives this : ec = 72057594037927935
and the second always gives this : ec = 0
so the problem is that when my program is executed in bacticks at times
does not give the correct exit code(i am sure that the command is
executed in bacticks cause i get the correct output ) but when execute
using system never gives incorrect exit code .
And this is happening only on one particular linux machine whoes
configuration i mentioned before.
I am using pthreads in my program.Also my main function does not join
on all the threads it creates.
I wrote 2 sample programs. One in which main thread joins on the
threads it creates and the other in which it does not.
The first one when executed in bacticks gives the same exit code
(72057594037927935)
but gives 0 exit code when executed throught system .This is again
happening only on that particular linux machine.I did not see any exit
code problems on any other machine(solaris , linux.AIX etc)
The second sample program never returned exit code (72057594037927935)
when executed in backticks
I feel there is some problem with that particular linux machine.cause i
dont this happening on any other machine. or it is a known fact that
when main thread does not join on the threads it creates , there could
be something wrong in the exit code of the program( mind you the exit
code is correct always when executed through system).