qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mte...@apache.org
Subject svn commit: r752015 - /qpid/trunk/qpid/cpp/src/qpid/sys/solaris/SystemInfo.cpp
Date Tue, 10 Mar 2009 08:12:14 GMT
Author: mteira
Date: Tue Mar 10 08:12:13 2009
New Revision: 752015

URL: http://svn.apache.org/viewvc?rev=752015&view=rev
Log:
qpid/sys/solaris/SystemInfo.cpp
 - Add a processName() solaris implementation

Modified:
    qpid/trunk/qpid/cpp/src/qpid/sys/solaris/SystemInfo.cpp

Modified: qpid/trunk/qpid/cpp/src/qpid/sys/solaris/SystemInfo.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/sys/solaris/SystemInfo.cpp?rev=752015&r1=752014&r2=752015&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/sys/solaris/SystemInfo.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/sys/solaris/SystemInfo.cpp Tue Mar 10 08:12:13 2009
@@ -33,7 +33,12 @@
 #include <sys/socket.h>
 #include <netinet/in.h>
 #include <arpa/inet.h>
+#include <stdio.h>
 #include <errno.h>
+#include <limits.h>
+#include <procfs.h>
+#include <fcntl.h>
+#include <sys/types.h>
 
 using namespace std;
 
@@ -56,12 +61,12 @@
 
 void SystemInfo::getLocalIpAddresses(uint16_t port,
                                      std::vector<Address> &addrList) {
-    int s = socket (PF_INET, SOCK_STREAM, 0);
+    int s = socket(PF_INET, SOCK_STREAM, 0);
     for (int i=1;;i++) {
         struct lifreq ifr;
         ifr.lifr_index = i;
         if (::ioctl(s, SIOCGIFADDR, &ifr) < 0) {
-            continue;
+            break;
         }
         struct sockaddr_in *sin = (struct sockaddr_in *) &ifr.lifr_addr;
         std::string addr(inet_ntoa(sin->sin_addr));
@@ -99,6 +104,20 @@
     return (uint32_t) ::getppid();
 }
 
-
+string SystemInfo::getProcessName()
+{
+    psinfo processInfo;
+    char procfile[PATH_MAX];
+    int fd;
+    string value;
+
+    snprintf(procfile, PATH_MAX, "/proc/%d/psinfo", getProcessId());
+    if ((fd = open(procfile, O_RDONLY)) >= 0) {
+        if (read(fd, (void *) &processInfo, sizeof(processInfo)) == sizeof(processInfo))
{
+            value = processInfo.pr_fname;
+        }
+    }
+    return value;
+}
 
 }} // namespace qpid::sys



---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:commits-subscribe@qpid.apache.org


Mime
View raw message