summaryrefslogtreecommitdiffstats
path: root/ctdb/common/system_freebsd.c
diff options
context:
space:
mode:
Diffstat (limited to 'ctdb/common/system_freebsd.c')
-rw-r--r--ctdb/common/system_freebsd.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/ctdb/common/system_freebsd.c b/ctdb/common/system_freebsd.c
index 2fb3f45ebd..1ce9d3d16d 100644
--- a/ctdb/common/system_freebsd.c
+++ b/ctdb/common/system_freebsd.c
@@ -372,7 +372,21 @@ int ctdb_get_peer_pid(const int fd, pid_t *peer_pid)
char *ctdb_get_process_name(pid_t pid)
{
- /* FIXME FreeBSD: get_process_name not implemented */
+ char path[32];
+ char buf[PATH_MAX];
+ char *ptr;
+ int n;
+
+ snprintf(path, sizeof(path), "/proc/%d/exe", pid);
+ n = readlink(path, buf, sizeof(buf));
+ if (n < 0) {
+ return NULL;
+ }
+
+ /* Remove any extra fields */
+ buf[n] = '\0';
+ ptr = strtok(buf, " ");
+ return strdup(ptr);
return NULL;
}