tags:

views:

175

answers:

2

Seeing some strange behavior, whereby connecting to Oracle database, and then calling external function, the value of $? is always -1.
Problem machine is running standard AIX5.3, with DBD::Oracle 1.20 and DBI 1.602.

#!/usr/bin/perl -w
use DBI;

CORE::system "pwd";
print "Before connect: $?\n";
DBI->connect('dbi:Oracle:', 'pwd', 'pwd');
print "Before system: $?\n";
CORE::system "pwd";
print "After system: $?\n";
CORE::system "pwd";
print "After system: $?\n";

Before connect: 0
Before system: 0
/usr/local/bin
After system: -1
/usr/local/bin
After system: -1

This is the results from a different AIX 5.3 machine, the only difference I can see is that it is running DBD:Oracle 1.22 and DBI 1.607. However looking at the change logs for those modules, I can't see anything that could relate to that. Any ideas for further things I can try other than upgrading DBD:Oracle and DBI (hesitent to do that straight away as this is a production machine).

+1  A: 

from perldoc -f system:

Return value of -1 indicates a failure to start the program or an error of the wait(2) system call (inspect $! for the reason).

It looks like the system call is not able to exec the pwd program anymore. Try changing your system calls to:

my $rc = system "pwd";
if ($rc == -1) {
    die "system call failed: $!";
} elsif ($rc & 0b0000_0000_0111_1111) {
    die "system call died due to signal ", $rc & 0b0000_0000_0111_1111;
} elsif ($rc & 0b1111_1111_0000_0000) {
    warn "system call returned non-zero exit code: ", $rc >> 8;
}
Chas. Owens
Gives the following output:/usr/local/binsystem call failed: There are no child processes. at ./test.pl line 7.Note that the actual pwd command itself completed (outputting /usr/local/bin).
Patrick
Based on that error message, found the following link, seems to be the same behavior:http://rt.cpan.org/Public/Bug/Display.html?id=16548
Patrick
Based on the one of the comments there, I added the following after the connection:$SIG{CHLD} = 'DEFAULT';That seems to fix (or work around the problem), thanks for the information about how to get the extra error message.
Patrick
A: 

I realise this posting is several months after the fact, but since I have encountered the same problem, I'll detail my workaround for anyone who stumbles on your post.

Different versions of the Oracle OCI libraries handle SIGCHILD separately (e.g. I have your problem with 11gR2 but not 11gR1). If you avoid using bequeath connections by changing

DBI->connect('dbi:Oracle:', 'pwd', 'pwd');

to

DBI->connect('dbi:Oracle:', 'pwd', 'pwd');

you'll find your problem goes away. Of course, you may not want to connect by going through the listener, but I don't have a solution for that...

Dan
I don't see any difference between the two statements you list. Have I missed something or is it a typo?
Patrick
I'm guessing, from the mention of going through listener, that the second one should beDBI->connect('dbi:Oracle:tnsconnect', 'pwd', 'pwd');where tnsconnect is a connection string.
Joe Watkins