Otherwise, values of command-line arguments, which are not explicitly
copied, can be corrupted by setproctitle().
/* proctitle.c */
+// Must be called before parsing of arguments
void setproctitle_init(int argc, char **argv);
void setproctitle(const char *msg, ...) FORMAT_CHECK(printf,1,2);
char *getproctitle(void);
if (spt_end+1 == oldenv[i])
spt_end = oldenv[i] + strlen(oldenv[i]);
+ /* Copy all arguments */
+ for (i=0; i<argc; i++)
+ argv[i] = xstrdup(argv[i]);
+
/* Recalculate program_invocation_name, otherwise syslog() will be confused. */
- char *name = xstrdup(argv[0]);
+ char *name = argv[0];
program_invocation_name = name;
char *p = strrchr(name, '/');
if (p)