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:35
Definition: errorbase.hpp:49
Definition: result.hpp:40
DWORD pid_t
Definition: windows.hpp:187
Try< Nothing > close(int fd)
Definition: close.hpp:24
Try< Nothing > utime(const std::string &path)
Definition: utime.hpp:32
Definition: duration.hpp:259
static Option< T > none()
Definition: option.hpp:31
bool isSome() const
Definition: try.hpp:70
static Try error(const E &e)
Definition: try.hpp:42
Result< std::string > read(int_fd fd, size_t size)
Definition: read.hpp:50
Result< Process > process(pid_t pid)
Definition: freebsd.hpp:30
bool isError() const
Definition: try.hpp:71
Try< int_fd > open(const std::string &path, int oflag, mode_t mode=0)
Definition: open.hpp:39
Definition: duration.hpp:217
std::string stringify(int flags)
Try< Memory > memory()
Definition: freebsd.hpp:78
Try< std::set< pid_t > > pids()
Definition: freebsd.hpp:62
#define O_RDONLY
Definition: fcntl.hpp:25
const T & get() const
Definition: try.hpp:73
Try< std::list< std::string > > ls(const std::string &directory)
Definition: ls.hpp:29