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

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

Thread Previous | Thread Next
From:
Richard Soderberg
Date:
August 2, 2001 00:42
Subject:
RE: [PATCH 2/4] -Wall cleanups: mg.c
Message ID:
NAEKLNAAHLMBPMPNBMLEIEPIDJAA.rs@oregonnet.com
From: Jarkko Hietaniemi [mailto:jhi@iki.fi]
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
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:

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


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