[ale] Perl Question

Mike Fletcher fletch at phydeaux.org
Wed Dec 8 17:27:48 EST 1999


>>>>> "Terry" == Terry Lee Tucker <terry at esc1.com> writes:

    Terry> I have a perl program that creates a daemon. I use the
    Terry> following syntax to change the name of the program to
    Terry> whatever I want:

    Terry> $0 = "myDaemon";

    Terry> This works find on Linux; howver, on brain dead SCO, it
    Terry> doesn't work. I really need to be able to assign a
    Terry> name. Does anyone have any experience with this? Any ideas,
    Terry> anyone?

        Assigning to $0 only works on OSen where the underlying OS
lets you write to argv[0].  You could test with a short C program:


#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>

int main( int argc, char **argv ) {
  printf( "Old argv[0]: %s\n", argv[ 0 ] );

  memset( argv[ 0 ], 0, strlen( argv[ 0 ] ) + 1 );
  strncpy( argv[ 0 ], "Boing!", 7 );

  printf( "New argv[0]: %s\n", argv[ 0 ] );

  /* Sleep to let you try a ps */
  sleep( 60 );

  exit( 0 );
}


        If that doesn't work, then perl's not going to be able to let
you muck with it through $0 either.

-- 
Fletch                | "If you find my answers frightening,       __`'/|
fletch at phydeaux.org   |  Vincent, you should cease askin'          \ o.O'
678 443-6239(w)       |  scary questions." -- Jules                =(___)=
                      |                                               U






More information about the Ale mailing list