Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

interpret a program's exit status

Status
Not open for further replies.

loosecannon1

Programmer
Feb 19, 2002
55
0
0
US
Hi All -

I'm *trying* to execute some JAVA from a PERL program...

The JAVA program doesn't run and I get a exit value of 139, which is useless to me.

How/where can I find the meaning of a returned exit value.

Any debugging ideas are appreciated. Thanks.

#------- SNIPPET---------
system($fop_cmd);
$return_value = $?;
$exit_value = $? >> 8;
$signal_num = $? & 127;
$dumped_core = $? & 128;
print OFILE "return_value = $return_value\n";
print OFILE "exit_value = $exit_value\n";
print OFILE "signal_num = $signal_num\n";
print OFILE "dumped_core = $dumped_core\n\n\n";
#------- SNIPPET---------


#---- OFILE ----------
return_value = 35584
exit_value = 139
signal_num = 0
dumped_core = 0
#---- OFILE ----------
 
Hmmm....

The only way to know what the exit code relates to is to decompile your java app and look at the code (unless of course it is well documented).

I am assuming that the java app runs fine with using the contents of $fop_cmd from the command line. Have you tried redirecting the output to a file and examine the results (the java app may output something useful at this stage)

i.e. $fop_cmd .= '> /tmp/fop_cmd.out 2>&1';

if that still does not work, you could try running the app under truss or strace (assuming you are using unix) and once again examine the output

i.e. $fop_cmd = 'truss '.$fop_cmd.' >/tmp/fop_cmd.out 2>&1';

The environment is also important for java, especially things like CLASSPATH. Is the app run directly or is it launched by a shell script? Is the environment correct when launching?

Try a few of these out first and let me know how you get on - I'll monitor the thread closely for a few days.

Cheers,
Scotty
 
Scotty,

Thanks for the info...

A little more about my environment, I'm running the app through a shell script on a Unix box.

I printed $fop_cmd -copy/pasted and ran it successfully from the cmd line.

I took your advice and piped the output to a file. The error message I get reads "Segmentation Fault".

The error seems to be intermittent...

I'm not sure what will cause or how to resolve the error...I'll keep digging. Thanks.
 
Does it segfault from the command line?

Mike

Want to get great answers to your Tek-Tips questions? Have a look at faq219-2884

It's like this; even samurai have teddy bears, and even teddy bears get drunk.
 
oh... ok

Have you compared your environment variables when running from the command line and from inside the Perl script?

From inside the Perl script you can get all the values of the environment variables that will be set in the shell that Perl starts for you, /bin/sh by the way, like this

foreach $var (keys %ENV){
print "$var = $ENV{$var}\n";
}

What shell are you using from the command line?


Mike

Want to get great answers to your Tek-Tips questions? Have a look at faq219-2884

It's like this; even samurai have teddy bears, and even teddy bears get drunk.
 
Thanks Mike,

I ended up pointing to another JVM and the darn thing worked.
 
ok <wry smile>...

Mike

Want to get great answers to your Tek-Tips questions? Have a look at faq219-2884

It's like this; even samurai have teddy bears, and even teddy bears get drunk.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top