From e865acedb89c5a464ec9d113acb0ed85f0865bf5 Mon Sep 17 00:00:00 2001 From: Kurt Hindenburg Date: Sun, 2 Jan 2011 21:13:06 +0000 Subject: [PATCH] Add cwd support for DragonFly. Patch by Alex Hornung. It compiles under Linux. BUG: 259970 svn path=/trunk/KDE/kdebase/apps/konsole/; revision=1210984 --- src/ProcessInfo.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/ProcessInfo.cpp b/src/ProcessInfo.cpp index 8332d7182..fbd8f20ae 100644 --- a/src/ProcessInfo.cpp +++ b/src/ProcessInfo.cpp @@ -58,6 +58,7 @@ #include //krazy:exclude=includes #include #include +#include #include #endif @@ -729,8 +730,22 @@ private: virtual bool readCurrentDir(int pid) { #if defined(__DragonFly__) - // Not supported in DragonFly - return false; + char buf[PATH_MAX]; + int managementInfoBase[4]; + size_t len; + + managementInfoBase[0] = CTL_KERN; + managementInfoBase[1] = KERN_PROC; + managementInfoBase[2] = KERN_PROC_CWD; + managementInfoBase[3] = pid; + + len = sizeof(buf); + if (sysctl(managementInfoBase, 4, buf, &len, NULL, 0) == -1) + return false; + + setCurrentDir(buf); + + return true; #else int numrecords; struct kinfo_file* info = 0;