summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/libc/gen/setproctitle.35
-rw-r--r--lib/libc/gen/setproctitle.c33
-rw-r--r--lib/libutil/setproctitle.35
-rw-r--r--lib/libutil/setproctitle.c33
4 files changed, 28 insertions, 48 deletions
diff --git a/lib/libc/gen/setproctitle.3 b/lib/libc/gen/setproctitle.3
index b2322b3..7fd157f 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 37b9fab..d0f224b 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);
diff --git a/lib/libutil/setproctitle.3 b/lib/libutil/setproctitle.3
index b2322b3..7fd157f 100644
--- a/lib/libutil/setproctitle.3
+++ b/lib/libutil/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/libutil/setproctitle.c b/lib/libutil/setproctitle.c
index 37b9fab..d0f224b 100644
--- a/lib/libutil/setproctitle.c
+++ b/lib/libutil/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);
OpenPOWER on IntegriCloud