develooper Front page | perl.perl5.porters | Postings from August 2001

Re: [PATCH 2/4] -Wall cleanups: mg.c

Thread Previous | Thread Next
From:
Jarkko Hietaniemi
Date:
August 2, 2001 06:30
Subject:
Re: [PATCH 2/4] -Wall cleanups: mg.c
Message ID:
20010802082751.K20071@chaos.wustl.edu
> 5.0-CURRENT reports in the man page:
>      The title is set from the executable's name, followed by the result
> of a
>      printf(3) style expansion of the arguments as specified by the fmt
> argu-
>      ment.  If the fmt argument begins with a ``-'' character, the exe-
>      cutable's name is skipped.
> 
> /usr/include/unistd.h:
> void     setproctitle __P((const char *_fmt, ...)) __printf0like(1, 2);
> 
> Well, wait a minute - it notes here that using '*' in the format gets it
> from the argument.  So maybe we need to be using the format string
> '-%*s' to use three argument.  RedHat printf documentation (heh) notes
> that the len comes first.  Thus, this:

The len-first version certainly makes more sense.

> --- mg.c~	Thu Aug  2 00:40:22 2001
> +++ mg.c	Thu Aug  2 00:39:29 2001
> @@ -2089,7 +2089,7 @@
>  	     * but not the "(perl) suffix from the ps(1)
>  	     * output, because that's what ps(1) shows if the
>  	     * argv[] is modified. */
> -	    setproctitle("-%s", s, len + 1);
> +	    setproctitle("-%*s", len + 1, s);
>  #   else	/* old FreeBSDs, NetBSD, OpenBSD, anyBSD */
>  	    /* This doesn't really work if you assume that
>  	     * $0 = 'foobar'; will wipe out 'perl' from the $0
> 
> Compiles without warnings, three arguments.  Yay!
> 
> R.

-- 
$jhi++; # http://www.iki.fi/jhi/
        # There is this special biologist word we use for 'stable'.
        # It is 'dead'. -- Jack Cohen

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About