Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 8 Jul 2003 09:11:20 -0700
From:      "Drew Tomlinson" <drew@mykitchentable.net>
To:        <dan@slightlystrange.org>, "FreeBSD Questions" <freebsd-questions@freebsd.org>
Subject:   Re: Can I Set Process Name?
Message-ID:  <00bf01c3456b$91e447e0$6e2a6ba5@lc.ca.gov>
References:  <20030708152937.GA91154@catflap.home.slightlystrange.org><008501c34567$a3f2eb20$6e2a6ba5@lc.ca.gov> <20030708160029.GB91154@catflap.home.slightlystrange.org>

next in thread | previous in thread | raw e-mail | index | archive | help
----- Original Message ----- 
From: "Daniel Bye" <dan@slightlystrange.org>
To: "FreeBSD Questions" <freebsd-questions@freebsd.org>
Sent: Tuesday, July 08, 2003 9:00 AM
Subject: Re: Can I Set Process Name?

> > On Tue, Jul 08, 2003 at 08:43:12AM -0700, Drew Tomlinson wrote:
> > > ----- Original Message ----- 
> > From: "Daniel Bye" <dan@slightlystrange.org>
> > To: "FreeBSD Questions" <freebsd-questions@freebsd.org>
> > Sent: Tuesday, July 08, 2003 8:29 AM
> >
> > On Tue, Jul 08, 2003 at 08:26:45AM -0700, Drew Tomlinson wrote:
> > > >
> > > > $0='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.
> >
> > > Yes - a `;' at the end of the line  ;-)
> >
> > 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.
>
> >
> > #!/usr/bin/perl
> > # A very simple perl web server used by Webmin
> >
> > $0='webmin';
> >
> > # Require basic libraries
> > package miniserv;    <-- This is just declaring that the following
> code is
>                            in the "miniserv" package.
> > use Socket;
> > use POSIX;
> >
> > Then a little farther in the script, I see this code:
> >
> > # Get miniserv's perl path and location
> > $miniserv_path = $0;
> > open(SOURCE, $miniserv_path);
> > <SOURCE> =~ /^#!(\S+)/; $perl_path = $1;
> > close(SOURCE);
> > @miniserv_argv = @ARGV;
> >
> > 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.

Thanks for the tutorial.  I'm going to drop this as it's not that
important.  I can always figure out which one is webmin as it is
listening on port 10000 and I can see it in the sockstat output.  I just
thought if I could change the name listed in ps, then I wouldn't have to
take the extra step to identify it.

Thanks,

Drew



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?00bf01c3456b$91e447e0$6e2a6ba5>