13 #ifndef __STOUT_OS_SUNOS_HPP__ 14 #define __STOUT_OS_SUNOS_HPP__ 18 #error "stout/os/sunos.hpp is only available on Solaris systems." 23 #include <sys/types.h> 43 std::string fn =
"/proc/" +
stringify(pid) +
"/status";
44 struct pstatus pstatus;
51 if (::
read(fd.get(), &pstatus,
sizeof(pstatus)) !=
sizeof(pstatus)) {
53 return Error(
"Cannot read from " + fn);
57 fn =
"/proc/" +
stringify(pid) +
"/psinfo";
65 if (::
read(fd.get(), &psinfo,
sizeof(psinfo)) !=
sizeof(psinfo)) {
67 return Error(
"Cannot read from " + fn);
76 return Process(pstatus.pr_pid,
84 (psinfo.pr_nzomb == 0) &&
85 (psinfo.pr_nlwp == 0) &&
86 (psinfo.pr_lwp.pr_lwpid == 0));
96 return Error(
"Failed to list files in /proc: " + entries.
error());
99 foreach (
const std::string& entry, entries.
get()) {
102 pids.insert(pid.
get());
110 return Error(
"Failed to determine pids from /proc");
117 return Error(
"Cannot determine the size of total and free memory");
122 #endif // __STOUT_OS_SUNOS_HPP__ Definition: errorbase.hpp:36
T & get()&
Definition: try.hpp:80
Try< int_fd > open(const std::string &path, int oflag, mode_t mode=0)
Definition: open.hpp:35
Definition: errorbase.hpp:50
Definition: posix_signalhandler.hpp:23
DWORD pid_t
Definition: windows.hpp:181
Try< Nothing > close(int fd)
Definition: close.hpp:24
Try< Nothing > utime(const std::string &path)
Definition: utime.hpp:32
Definition: duration.hpp:207
static Option< T > none()
Definition: option.hpp:32
bool isSome() const
Definition: try.hpp:77
static Try error(const E &e)
Definition: try.hpp:43
Result< std::string > read(int_fd fd, size_t size)
Definition: read.hpp:55
Result< Process > process(pid_t pid)
Definition: freebsd.hpp:30
bool isError() const
Definition: try.hpp:78
Definition: duration.hpp:165
std::string stringify(int flags)
Try< Memory > memory()
Definition: freebsd.hpp:78
Try< std::set< pid_t > > pids()
Definition: freebsd.hpp:62
Try< std::list< std::string > > ls(const std::string &directory)
Definition: ls.hpp:29