FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
node/src/platform_freebsd.cc at master · objcode/node · GitHub
objcode
/
node
Public
forked from
nodejs/node-v0.x-archive
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
node
/
src
/
platform_freebsd.cc
Copy path
More file actions
More file actions
Latest commit
History
History
History
80 lines (61 loc) · 1.44 KB
Breadcrumbs
node
/
src
/
platform_freebsd.cc
Copy path
File metadata and controls
80 lines (61 loc) · 1.44 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#
include
"
node.h
"
#
include
"
platform.h
"
#
include
<
stdlib.h
>
#
include
<
kvm.h
>
#
include
<
sys/param.h
>
#
include
<
sys/sysctl.h
>
#
include
<
sys/user.h
>
#
include
<
string.h
>
#
include
<
paths.h
>
#
include
<
fcntl.h
>
#
include
<
unistd.h
>
namespace
node
{
static
char
*process_title;
char
**
OS::SetupArgs
(
int
argc,
char
*argv[]) {
process_title = argc ?
strdup
(argv[
0
]) :
NULL
;
return
argv;
}
void
OS::SetProcessTitle
(
char
*title) {
if
(process_title)
free
(process_title);
process_title =
strdup
(title);
setproctitle
(title);
}
const
char
*
OS::GetProcessTitle
(
int
*len) {
if
(process_title) {
*len =
strlen
(process_title);
return
process_title;
}
*len =
0
;
return
NULL
;
}
int
OS::GetMemory
(
size_t
*rss,
size_t
*vsize) {
kvm_t
*kd =
NULL
;
struct
kinfo_proc
*kinfo =
NULL
;
pid_t
pid;
int
nprocs;
size_t
page_size =
getpagesize
();
pid =
getpid
();
kd =
kvm_open
(
NULL
, _PATH_DEVNULL,
NULL
,
O_RDONLY
,
"
kvm_open
"
);
if
(kd ==
NULL
)
goto
error;
kinfo =
kvm_getprocs
(kd,
KERN_PROC_PID
, pid, &nprocs);
if
(kinfo ==
NULL
)
goto
error;
*rss = kinfo->
ki_rssize
* page_size;
*vsize = kinfo->
ki_size
;
kvm_close
(kd);
return
0
;
error:
if
(kd)
kvm_close
(kd);
return
-
1
;
}
int
OS::GetExecutablePath
(
char
* buffer,
size_t
* size) {
int
mib[
4
];
mib[
0
] =
CTL_KERN
;
mib[
1
] =
KERN_PROC
;
mib[
2
] =
KERN_PROC_PATHNAME
;
mib[
3
] = -
1
;
if
(
sysctl
(mib,
4
, buffer, size,
NULL
,
0
) == -
1
) {
return
-
1
;
}
return
0
;
}
}
//
namespace node
Back
|
FazBrowse Home
|
New Git URL