summaryrefslogtreecommitdiff
path: root/cpp/src/qpid/sys/posix/SystemInfo.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src/qpid/sys/posix/SystemInfo.cpp')
-rwxr-xr-xcpp/src/qpid/sys/posix/SystemInfo.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/cpp/src/qpid/sys/posix/SystemInfo.cpp b/cpp/src/qpid/sys/posix/SystemInfo.cpp
index 938d4861c4..5d9eda605d 100755
--- a/cpp/src/qpid/sys/posix/SystemInfo.cpp
+++ b/cpp/src/qpid/sys/posix/SystemInfo.cpp
@@ -27,6 +27,9 @@
#include <arpa/inet.h>
#include <stdio.h>
#include <unistd.h>
+#include <iostream>
+#include <fstream>
+#include <sstream>
#ifndef HOST_NAME_MAX
# define HOST_NAME_MAX 256
@@ -104,6 +107,27 @@ uint32_t SystemInfo::getParentProcessId()
return (uint32_t) ::getppid();
}
+string SystemInfo::getProcessName()
+{
+ uint32_t pid = getProcessId();
+ string value;
+
+ stringstream pathStream;
+ pathStream << "/proc/" << pid << "/status";
+ ifstream input(pathStream.str().c_str());
+ if (input.good()) {
+ while (!input.eof()) {
+ string key;
+ input >> key;
+ if (key == "Name:") {
+ input >> value;
+ break;
+ }
+ }
+ input.close();
+ }
+ return value;
+}
}} // namespace qpid::sys