]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
* nscd/connections.c (restart): Try to preserve the process name
authorUlrich Drepper <drepper@redhat.com>
Mon, 16 Mar 2009 22:33:01 +0000 (22:33 +0000)
committerUlrich Drepper <drepper@redhat.com>
Mon, 16 Mar 2009 22:33:01 +0000 (22:33 +0000)
by reading the /proc/self/exe symlink and using the return name.
Patch by Jeff Bastian <jbastian@redhat.com>.

ChangeLog
nscd/connections.c

index 8911e9750d4f7a24ee6e42320a5a952795c180d5..3bb4ed1204fe9c2540bc86bf3296697c8cd6c945 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2009-03-16  Ulrich Drepper  <drepper@redhat.com>
+
+       * 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 <jbastian@redhat.com>.
+
 2009-03-15  Ulrich Drepper  <drepper@redhat.com>
 
        [BZ #9733]
index 3d0727f33b2a3f0667531e42f65ae3171f623859..234e289f008df2a27f488e6b16f24ff93a7ecf34 100644 (file)
@@ -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"),