From: Ulrich Drepper Date: Mon, 16 Mar 2009 22:33:01 +0000 (+0000) Subject: * nscd/connections.c (restart): Try to preserve the process name X-Git-Tag: cvs/fedora-glibc-20090320T1944~5 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d9822dbe663a7cefe32979e09a186f739ea8b769;p=platform%2Fupstream%2Fglibc.git * nscd/connections.c (restart): Try to preserve the process name by reading the /proc/self/exe symlink and using the return name. Patch by Jeff Bastian . --- diff --git a/ChangeLog b/ChangeLog index 8911e97..3bb4ed1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2009-03-16 Ulrich Drepper + + * nscd/connections.c (restart): Try to preserve the process name + by reading the /proc/self/exe symlink and using the return name. + Patch by Jeff Bastian . + 2009-03-15 Ulrich Drepper [BZ #9733] diff --git a/nscd/connections.c b/nscd/connections.c index 3d0727f..234e289 100644 --- a/nscd/connections.c +++ b/nscd/connections.c @@ -1418,7 +1418,22 @@ cannot change to old working directory: %s; disabling paranoia mode"), } /* The preparations are done. */ - execv ("/proc/self/exe", argv); +#ifdef PATH_MAX + char pathbuf[PATH_MAX]; +#else + char pathbuf[256]; +#endif + /* Try to exec the real nscd program so the process name (as reported + in /proc/PID/status) will be 'nscd', but fall back to /proc/self/exe + if readlink fails */ + ssize_t n = readlink ("/proc/self/exe", pathbuf, sizeof (pathbuf) - 1); + if (n == -1) + execv ("/proc/self/exe", argv); + else + { + pathbuf[n] = '\0'; + execv (pathbuf, argv); + } /* If we come here, we will never be able to re-exec. */ dbg_log (_("re-exec failed: %s; disabling paranoia mode"),