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

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

Thread Previous | Thread Next
Richard Soderberg
August 2, 2001 00:42
RE: [PATCH 2/4] -Wall cleanups: mg.c
Message ID:
From: Jarkko Hietaniemi []
Subject: Re: [PATCH 2/4] -Wall cleanups: mg.c
> > This removes the third argument from the use of the
> function, resolving the
> > warning.
> Hmmm.  The three-arg version was added on purpose a year ago (change
> #6483).  I must investigate more, maybe this is something dependent
> on the Frisbee version.

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
     ment.  If the fmt argument begins with a ``-'' character, the exe-
     cutable's name is skipped.

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:

--- 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!


Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About