Date: Tue, 8 Jul 2003 17:00:29 +0100 From: Daniel Bye <dan@slightlystrange.org> To: FreeBSD Questions <freebsd-questions@freebsd.org> Subject: Re: Can I Set Process Name? Message-ID: <20030708160029.GB91154@catflap.home.slightlystrange.org> In-Reply-To: <008501c34567$a3f2eb20$6e2a6ba5@lc.ca.gov> References: <20030708152937.GA91154@catflap.home.slightlystrange.org> <008501c34567$a3f2eb20$6e2a6ba5@lc.ca.gov>
next in thread | previous in thread | raw e-mail | index | archive | help
--cmJC7u66zC7hs+87
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
On Tue, Jul 08, 2003 at 08:43:12AM -0700, Drew Tomlinson wrote:
> ----- Original Message -----=20
> From: "Daniel Bye" <dan@slightlystrange.org>
> To: "FreeBSD Questions" <freebsd-questions@freebsd.org>
> Sent: Tuesday, July 08, 2003 8:29 AM
>=20
> On Tue, Jul 08, 2003 at 08:26:45AM -0700, Drew Tomlinson wrote:
> > >
> > > $0=3D'webmin';
>              ^
> > >
> > > However when starting the program it dies with the following
> message:
> > >
> > > Is there something really easy I'm missing?  If it's complicated I'm
> > > going to forget it as it's not that important.
>=20
> > Yes - a `;' at the end of the line  ;-)
>=20
> Thanks.  That removed the error but failed to change the process name.
> I looked at the code a little more.  I'm not experienced in this but it
> seems to me that the 'package miniserv;' line calls a precompiled
> program?  Here's the beginning of the script:
No - in Perl, a "package" is a namespace - an abstract storage space.  It
helps keep a module's (i.e. package's) variables etc logically separate from
those of other packages.  It prevents collisions in variable names, data
structures, etc.
The variable $0 contains, by default, the name of the file containing the
currently running script. =20
>=20
> #!/usr/bin/perl
> # A very simple perl web server used by Webmin
>=20
> $0=3D'webmin';
>=20
> # Require basic libraries
> package miniserv;    <-- This is just declaring that the following code is
                           in the "miniserv" package.
> use Socket;
> use POSIX;
>=20
> Then a little farther in the script, I see this code:
>=20
> # Get miniserv's perl path and location
> $miniserv_path =3D $0;   =20
> open(SOURCE, $miniserv_path);
> <SOURCE> =3D~ /^#!(\S+)/; $perl_path =3D $1;
> close(SOURCE);
> @miniserv_argv =3D @ARGV;
>=20
> So I suspect the process name gets set in this somewhere?
As you have poked $0 before it gets this far, no - $0 contains the value you
set above.  Which might, in itself, cause problems later in the script.
Without reviewing it, I couldn't tell you.
Dan
--=20
Daniel Bye
PGP Key: ftp://ftp.slightlystrange.org/pgpkey/dan.asc
PGP Key fingerprint: 3B9D 8BBB EB03 BA83 5DB4 3B88 86FC F03A 90A1 BE8F
                                                                     _
                                              ASCII ribbon campaign ( )
                                         - against HTML, vCards and  X
                                - proprietary attachments in e-mail / \
--cmJC7u66zC7hs+87
Content-Type: application/pgp-signature
Content-Disposition: inline
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (FreeBSD)
iD8DBQE/CuqdhvzwOpChvo8RAtzrAJ99wKddO3E/VDA5KZuVw2NwyDEBnwCdHdUF
bQgoZuBUB+WuUI6Q6GwCFaU=
=nJtV
-----END PGP SIGNATURE-----
--cmJC7u66zC7hs+87--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030708160029.GB91154>
