Tue Aug 18 07:58:53 2009: Request 48770 was acted upon.
Transaction: Correspondence added by RSCHUPP
       Queue: PAR
     Subject: $0 is not working when PAR is used
   Broken in: (no value)
    Severity: (no value)
       Owner: Nobody
  Requestors: mianro...@hotmail.com
      Status: open
 Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=48770 >


On Tue Aug 18 05:16:49 2009, mianro...@hotmail.com wrote:
> As you have shown, you have gone one step further, it seems the issue
> is related with
> the shrink of the environment but I think this is something quite
> weird.

It's not so weird if you know how most Unixes (including Linux)
implement the passing of arguments + environment to a program
(i.e. across execve) and how ps gets its information.

>      The issue I see here is that there is a command (not PAR'ed )
> that is working properly,
> and then, when it is PAR'ed, it has different behaviour, which this is
> something I see not acceptable.

As I've said before, your example "works" by accident
(albeit chances are good that it works most of the time).
The perlvar man page explains that setting $0 and how this
is reflected in ps etc are highly OS dependent and the only
thing you could reasonably expect is up to the length of
the original $0 (and that's what you observe).

In general, it is NOT reasonable to expect that a packed program
will behave absoolutely identical to the original script. PAR tries
hard and jumps thru several hoops to make some stupid constructs
magically work out of the box. But there are known cases, where
it doesn't work and you have to change your expectations and
your code.

>      My point heres are 2 then:
> 
> Could this be fixed?
> If not, could it be a workaround in which this "shrinking" environment
> in the PAR files could be overcome and the behaviour of the programs
> are not changed?

It might be possible to rewrite the handling of argv and envp
in PAR::Packer (actually it's parl as embedded in every 
packed executable) so that the "shrinking" of the environment
can be avoided.

Patches welcome, the stuff is in myldr/*.c in the PAR::Packer source.
You might want to consult the Perl source (mg.c and perl.c in
particular) to study the contortions Perl has to go thru to 
implement the current behaviour.

Reply via email to