diff options
Diffstat (limited to 'openbsd-compat/setproctitle.c')
-rw-r--r-- | openbsd-compat/setproctitle.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/openbsd-compat/setproctitle.c b/openbsd-compat/setproctitle.c index b511f6649..2965f689e 100644 --- a/openbsd-compat/setproctitle.c +++ b/openbsd-compat/setproctitle.c | |||
@@ -43,6 +43,8 @@ | |||
43 | #endif | 43 | #endif |
44 | #include <string.h> | 44 | #include <string.h> |
45 | 45 | ||
46 | #include <vis.h> | ||
47 | |||
46 | #define SPT_NONE 0 /* don't use it at all */ | 48 | #define SPT_NONE 0 /* don't use it at all */ |
47 | #define SPT_PSTAT 1 /* use pstat(PSTAT_SETCMD, ...) */ | 49 | #define SPT_PSTAT 1 /* use pstat(PSTAT_SETCMD, ...) */ |
48 | #define SPT_REUSEARGV 2 /* cover argv with title information */ | 50 | #define SPT_REUSEARGV 2 /* cover argv with title information */ |
@@ -121,7 +123,7 @@ setproctitle(const char *fmt, ...) | |||
121 | { | 123 | { |
122 | #if SPT_TYPE != SPT_NONE | 124 | #if SPT_TYPE != SPT_NONE |
123 | va_list ap; | 125 | va_list ap; |
124 | char buf[1024]; | 126 | char buf[1024], ptitle[1024]; |
125 | size_t len; | 127 | size_t len; |
126 | extern char *__progname; | 128 | extern char *__progname; |
127 | #if SPT_TYPE == SPT_PSTAT | 129 | #if SPT_TYPE == SPT_PSTAT |
@@ -142,14 +144,16 @@ setproctitle(const char *fmt, ...) | |||
142 | vsnprintf(buf + len, sizeof(buf) - len , fmt, ap); | 144 | vsnprintf(buf + len, sizeof(buf) - len , fmt, ap); |
143 | } | 145 | } |
144 | va_end(ap); | 146 | va_end(ap); |
147 | strnvis(ptitle, buf, sizeof(ptitle), | ||
148 | VIS_CSTYLE|VIS_NL|VIS_TAB|VIS_OCTAL); | ||
145 | 149 | ||
146 | #if SPT_TYPE == SPT_PSTAT | 150 | #if SPT_TYPE == SPT_PSTAT |
147 | pst.pst_command = buf; | 151 | pst.pst_command = ptitle; |
148 | pstat(PSTAT_SETCMD, pst, strlen(buf), 0, 0); | 152 | pstat(PSTAT_SETCMD, pst, strlen(ptitle), 0, 0); |
149 | #elif SPT_TYPE == SPT_REUSEARGV | 153 | #elif SPT_TYPE == SPT_REUSEARGV |
150 | /* debug("setproctitle: copy \"%s\" into len %d", | 154 | /* debug("setproctitle: copy \"%s\" into len %d", |
151 | buf, argv_env_len); */ | 155 | buf, argv_env_len); */ |
152 | len = strlcpy(argv_start, buf, argv_env_len); | 156 | len = strlcpy(argv_start, ptitle, argv_env_len); |
153 | for(; len < argv_env_len; len++) | 157 | for(; len < argv_env_len; len++) |
154 | argv_start[len] = SPT_PADCHAR; | 158 | argv_start[len] = SPT_PADCHAR; |
155 | #endif | 159 | #endif |