Hi,
I am using perl v5.36 and PAR:Packer 1.057 and would appreciate some insight 
into the exit code behavior as seen by the OS. Question at the end:

Code:
==========================
use strict;
use warnings;
my $exit_code = $ARGV[0];
print "called with $0 $exit_code\n";

END {
    $? = $exit_code;     #  Setting this in case exit is ignoring our exit_code 
    print STDERR "Exiting final with exit_status $exit_code, ? = $? \n";
    exit ($exit_code);
}
===============================

What is strange is that, running under perl (raw code), all exit codes work 
i.e. under Linux:
[dkhosla]$ perl t.pl 2
called with t.pl 2
Exiting final with exit_status 2, ? = 2
[dkhosla]$ echo $?
2

[dkhosla]$ perl t.pl 1
called with t.pl 1
Exiting final with exit_status 1, ? = 1
[dkhosla]$ echo $?
1

[dkhosla]$ perl t.pl 0
called with t.pl 0
Exiting final with exit_status 0, ? = 0
[dkhosla]$ echo $?
0

But running the packaged version - I get varied results. The sample code always 
returns 0 for $? But my bigger piece of code provides proper code for 0 or 2, 
but a 0 when exiting with a 1. 
[dkhosla]$ ./t 2
called with ./t 2
Exiting final with exit_status 2, ? = 2
[dkhosla]$ echo $?
0

I saw a note about trying 'POSIX::_exit' and that does fix the issue; but doing 
that noticed that STDOUT etc. is not fully flushed.
The questions are: 
- Should I be using 'POSIX::_exit' or there is a fix to the issue shown using 
std. perl 'exit' with PAR?
- If POSIX, what other 'cleanup' should I be concerned about taking care of 
aside from flushing STDOUT etc...?

Thanks for any guidance!

Regards, 
Deepak Khosla 
eXcellence in IS Solutions, Inc. (X-ISS) 
Email : dkho...@x-iss.com 

Reply via email to