FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
node/src/platform_sunos.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_sunos.cc
Copy path
More file actions
More file actions
Latest commit
History
History
History
90 lines (62 loc) · 1.62 KB
Breadcrumbs
node
/
src
/
platform_sunos.cc
Copy path
File metadata and controls
90 lines (62 loc) · 1.62 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
81
82
83
84
85
86
87
88
89
#
include
"
node.h
"
#
include
"
platform.h
"
#
include
<
unistd.h
>
/*
getpagesize()
*/
#
include
<
stdlib.h
>
/*
getexecname()
*/
#
include
<
strings.h
>
/*
strncpy()
*/
#
if
(!defined(_LP64)) && (_FILE_OFFSET_BITS - 0 == 64)
#
define
PROCFS_FILE_OFFSET_BITS_HACK
1
#
undef
_FILE_OFFSET_BITS
#
else
#
define
PROCFS_FILE_OFFSET_BITS_HACK
0
#
endif
#
include
<
procfs.h
>
#
if
(PROCFS_FILE_OFFSET_BITS_HACK - 0 == 1)
#
define
_FILE_OFFSET_BITS
64
#
endif
namespace
node
{
char
**
OS::SetupArgs
(
int
argc,
char
*argv[]) {
return
argv;
}
void
OS::SetProcessTitle
(
char
*title) {
;
}
const
char
*
OS::GetProcessTitle
(
int
*len) {
*len =
0
;
return
NULL
;
}
int
OS::GetMemory
(
size_t
*rss,
size_t
*vsize) {
pid_t
pid =
getpid
();
size_t
page_size =
getpagesize
();
char
pidpath[
1024
];
sprintf
(pidpath,
"
/proc/%d/psinfo
"
, pid);
psinfo_t
psinfo;
FILE
*f =
fopen
(pidpath,
"
r
"
);
if
(!f)
return
-
1
;
if
(
fread
(&psinfo,
sizeof
(
psinfo_t
),
1
, f) !=
1
) {
fclose
(f);
return
-
1
;
}
/*
XXX correct?
*/
*vsize = (
size_t
) psinfo.
pr_size
* page_size;
*rss = (
size_t
) psinfo.
pr_rssize
*
1024
;
fclose
(f);
return
0
;
}
int
OS::GetExecutablePath
(
char
* buffer,
size_t
* size) {
const
char
*execname =
getexecname
();
if
(!execname)
return
-
1
;
if
(execname[
0
] ==
'
/
'
) {
char
*result =
strncpy
(buffer, execname, *size);
*size =
strlen
(result);
}
else
{
char
*result =
getcwd
(buffer, *size);
if
(!result)
return
-
1
;
result =
strncat
(buffer,
"
/
"
, *size);
if
(!result)
return
-
1
;
result =
strncat
(buffer, execname, *size);
if
(!result)
return
-
1
;
*size =
strlen
(result);
}
return
0
;
}
}
//
namespace node
Back
|
FazBrowse Home
|
New Git URL