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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

rc=65535

Status
Not open for further replies.

svar

Programmer
Aug 12, 2001
349
GR
what is rc=65535?
I have a system call
my $rc=system("cp $a") where $a is a string like file1 file2
This works in the vast majority of times
but sometimes returns a nonzero rc, in this case rc=65535.

Where ca I get an explanation for what this means
 
65535 = -1 in a 16 bit integer.
I would suggest that the "cp" is returning an error code of -1.
The "man" page for "cp" suggests that a non-zero return code warns of failure.


Trojan.
 
Right, but what exactly is failing? There's plenty of disk space the disks are brand new. Plus after a few times
the code runs with no such failures. In the net I found
that this code is associated with SCSI disks and old M/Bs for kernel versions prior to 2.3(I have 2.6.13)-this is Linux Slack 10.2 btw
 
Could be lots of things.
Permissions for example?
Your code does "cp $a" and $a might not contain what you think it does.
Why not add a line that says:
Code:
  print "\$a is [$a]\n"  if($rc != 0);


Trojan.
 
Do you have a sort() operation earlier in your program? Aren't $a and $b reserved for sort() operations? Might be changing in that sort, if there is one...
 
$a and $b are not reserved.

From the documentation

You can check all the failure possibilities by inspecting $? like this:
Code:
    if ($? == -1) {
        print "failed to execute: $!\n";
    }
    elsif ($? & 127) {
        printf "child died with signal %d, %s coredump\n",
            ($? & 127),  ($? & 128) ? 'with' : 'without';
    }
    else {
        printf "child exited with value %d\n", $? >> 8;
    }

Now the signal check is UNIX based, so you can ignore that. But the first and third checks are relevant.

Another way of writing that third check would be:
Code:
$rc = $? >> 8;
print "child exited with value $rc\n";
print "\$! = $!\n";
Having a look in $! after a failure is always a good idea.

Mike

I am not inscrutable. [orientalbow]

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

 
Here are more detailed diagnostics:
It looks like the reason was: cannot alocate memory(for a system call like cp??!!)!!
top did not complain about memory. I suspect the problem is
much more serious(after storing and deleting large
datastructures which is what the program does, I simply cannot believe it
lacks the memory for a cp!). It does not happen on other machines with less memory even(I have 2GB RAM here)



copy /home/myuser/AFILES/s7ermsc1.0.2.gz to /home/myuser/DFILES/s7ermsc1.0.2.av.gz from AFILES to DFILES failed with 65535.
Exclam point is Cannot allocate memory
child exited with value %d
not copied ( cp /home/myuser/AFILES/s7ermsc1.0.2.av.gz /home/myuser/DFILES/s7ermsc1.0.2.av.gz )
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top