From: Martin Mares Date: Fri, 19 Aug 2011 15:17:45 +0000 (+0200) Subject: Let setproctitle() recalculate program_invocation_name X-Git-Tag: v5.0~109 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=accd8b1d1844b0f9634b1e6a6d1f1be9d63eece1;p=libucw.git Let setproctitle() recalculate program_invocation_name Otherwise, syslog() and other functions which try to log the name of the current programs are confused. --- diff --git a/ucw/proctitle.c b/ucw/proctitle.c index 30e8c05d..c1f8ff78 100644 --- a/ucw/proctitle.c +++ b/ucw/proctitle.c @@ -13,6 +13,7 @@ #include #include #include +#include static char **spt_argv; static char *spt_start, *spt_end; @@ -50,6 +51,15 @@ setproctitle_init(int argc, char **argv) for (i=0; oldenv[i]; i++) if (spt_end+1 == oldenv[i]) spt_end = oldenv[i] + strlen(oldenv[i]); + + /* Recalculate program_invocation_name, otherwise syslog() will be confused. */ + char *name = xstrdup(argv[0]); + program_invocation_name = name; + char *p = strrchr(name, '/'); + if (p) + program_invocation_short_name = p + 1; + else + program_invocation_short_name = name; #endif }