summaryrefslogtreecommitdiff
path: root/lib/libc
diff options
context:
space:
mode:
authorPaul Saab <ps@FreeBSD.org>2000-08-01 06:37:09 +0000
committerPaul Saab <ps@FreeBSD.org>2000-08-01 06:37:09 +0000
commit305ad8f90883326d5f36cd372dea91c3f0655dd1 (patch)
tree74a878b730b158661a4bf15248e1d5f9b677f627 /lib/libc
parentb09b0095944b8915df05ca12611f72a9a34f233d (diff)
Notes
Diffstat (limited to 'lib/libc')
-rw-r--r--lib/libc/gen/setproctitle.35
-rw-r--r--lib/libc/gen/setproctitle.c33
2 files changed, 14 insertions, 24 deletions
diff --git a/lib/libc/gen/setproctitle.3 b/lib/libc/gen/setproctitle.3
index b2322b3397de..7fd157f857a7 100644
--- a/lib/libc/gen/setproctitle.3
+++ b/lib/libc/gen/setproctitle.3
@@ -47,6 +47,11 @@ result of a
style expansion of the arguments as specified by the
.Va fmt
argument.
+If the
+.Va fmt
+argument begins with a
+.Dq -
+character, the executable's name is skipped.
.Pp
If
.Va fmt
diff --git a/lib/libc/gen/setproctitle.c b/lib/libc/gen/setproctitle.c
index 37b9fab52b3a..d0f224bff86d 100644
--- a/lib/libc/gen/setproctitle.c
+++ b/lib/libc/gen/setproctitle.c
@@ -49,24 +49,13 @@ struct old_ps_strings {
#define OLD_PS_STRINGS ((struct old_ps_strings *) \
(USRSTACK - SPARE_USRSPACE - sizeof(struct old_ps_strings)))
-#if defined(__STDC__) /* from other parts of sendmail */
#include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
-
#define SPT_BUFSIZE 2048 /* from other parts of sendmail */
extern char * __progname; /* is this defined in a .h anywhere? */
void
-#if defined(__STDC__)
setproctitle(const char *fmt, ...)
-#else
-setproctitle(fmt, va_alist)
- const char *fmt;
- va_dcl
-#endif
{
static struct ps_strings *ps_strings;
static char buf[SPT_BUFSIZE];
@@ -81,24 +70,20 @@ setproctitle(fmt, va_alist)
unsigned long ul_ps_strings;
int oid[4];
-#if defined(__STDC__)
va_start(ap, fmt);
-#else
- va_start(ap);
-#endif
if (fmt) {
buf[sizeof(buf) - 1] = '\0';
- /* print program name heading for grep */
- (void) snprintf(buf, sizeof(buf), "%s: ", __progname);
-
- /*
- * can't use return from sprintf, as that is the count of how
- * much it wanted to write, not how much it actually did.
- */
-
- len = strlen(buf);
+ if (fmt[0] == '-') {
+ /* skip program name prefix */
+ fmt++;
+ len = 0;
+ } else {
+ /* print program name heading for grep */
+ (void) snprintf(buf, sizeof(buf), "%s: ", __progname);
+ len = strlen(buf);
+ }
/* print the argument string */
(void) vsnprintf(buf + len, sizeof(buf) - len, fmt, ap);