Sophie

Sophie

distrib > Scientific%20Linux > 5x > x86_64 > by-pkgid > 2003d1abfa0c20ee77815f0da33e2c1c > files > 215

glibc-2.5-49.el5_5.5.src.rpm

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>.

--- libc/nscd/connections.c	13 Feb 2009 20:35:02 -0000	1.126
+++ libc/nscd/connections.c	16 Mar 2009 22:32:33 -0000	1.127
@@ -1418,7 +1418,22 @@ cannot change to old working directory: 
       }
 
   /* 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"),