aboutsummaryrefslogtreecommitdiff
path: root/nscd/connections.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2009-03-16 22:33:01 +0000
committerUlrich Drepper <drepper@redhat.com>2009-03-16 22:33:01 +0000
commitd9822dbe663a7cefe32979e09a186f739ea8b769 (patch)
tree223a75f50009f160812a894cb187a71b64976d2c /nscd/connections.c
parent2ca285b098890abde89fc79bbaf69432b14f18d1 (diff)
downloadglibc-d9822dbe663a7cefe32979e09a186f739ea8b769.tar
glibc-d9822dbe663a7cefe32979e09a186f739ea8b769.tar.gz
glibc-d9822dbe663a7cefe32979e09a186f739ea8b769.tar.bz2
glibc-d9822dbe663a7cefe32979e09a186f739ea8b769.zip
* 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>.
Diffstat (limited to 'nscd/connections.c')
-rw-r--r--nscd/connections.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/nscd/connections.c b/nscd/connections.c
index 3d0727f33b..234e289f00 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"),