|
@ -1,34 +1,41 @@ |
|
|
#include "node.h" |
|
|
#include "node.h" |
|
|
#include "platform.h" |
|
|
#include "platform.h" |
|
|
|
|
|
|
|
|
|
|
|
#include <stdlib.h> |
|
|
#include <kvm.h> |
|
|
#include <kvm.h> |
|
|
#include <sys/param.h> |
|
|
#include <sys/param.h> |
|
|
#include <sys/sysctl.h> |
|
|
#include <sys/sysctl.h> |
|
|
#include <sys/user.h> |
|
|
#include <sys/user.h> |
|
|
|
|
|
#include <string.h> |
|
|
#include <paths.h> |
|
|
#include <paths.h> |
|
|
#include <fcntl.h> |
|
|
#include <fcntl.h> |
|
|
#include <unistd.h> |
|
|
#include <unistd.h> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace node { |
|
|
namespace node { |
|
|
|
|
|
static char *process_title; |
|
|
|
|
|
|
|
|
char** OS::SetupArgs(int argc, char *argv[]) { |
|
|
char** OS::SetupArgs(int argc, char *argv[]) { |
|
|
|
|
|
process_title = argc ? strdup(argv[0]) : NULL; |
|
|
return argv; |
|
|
return argv; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void OS::SetProcessTitle(char *title) { |
|
|
void OS::SetProcessTitle(char *title) { |
|
|
; |
|
|
if (process_title) free(process_title); |
|
|
|
|
|
process_title = strdup(title); |
|
|
|
|
|
setproctitle(title); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const char* OS::GetProcessTitle(int *len) { |
|
|
const char* OS::GetProcessTitle(int *len) { |
|
|
|
|
|
if (process_title) { |
|
|
|
|
|
*len = strlen(process_title); |
|
|
|
|
|
return process_title; |
|
|
|
|
|
} |
|
|
*len = 0; |
|
|
*len = 0; |
|
|
return NULL; |
|
|
return NULL; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int OS::GetMemory(size_t *rss, size_t *vsize) { |
|
|
int OS::GetMemory(size_t *rss, size_t *vsize) { |
|
|
kvm_t *kd = NULL; |
|
|
kvm_t *kd = NULL; |
|
|
struct kinfo_proc *kinfo = NULL; |
|
|
struct kinfo_proc *kinfo = NULL; |
|
|