FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
node/src/platform_darwin.cc at writev · sgithens/node · GitHub
sgithens
/
node
Public
forked from
nodejs/node-v0.x-archive
Notifications
You must be signed in to change notification settings
Fork
0
Star
1
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_darwin.cc
Copy path
More file actions
More file actions
Latest commit
History
History
History
71 lines (54 loc) · 1.54 KB
Breadcrumbs
node
/
src
/
platform_darwin.cc
Copy path
File metadata and controls
71 lines (54 loc) · 1.54 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
#
include
"
node.h
"
#
include
"
platform.h
"
#
include
<
mach/task.h
>
#
include
<
mach/mach_init.h
>
#
include
<
mach-o/dyld.h
>
/*
_NSGetExecutablePath
*/
#
include
<
limits.h
>
/*
PATH_MAX
*/
namespace
node
{
static
char
*process_title;
char
**
OS::SetupArgs
(
int
argc,
char
*argv[]) {
process_title = argc ?
strdup
(argv[
0
]) :
NULL
;
return
argv;
}
//
OS::SetProcessTitle implemented in platform_darwin_proctitle.cc
}
//
namespace node
#
include
"
platform_darwin_proctitle.cc
"
namespace
node
{
const
char
*
OS::GetProcessTitle
(
int
*len) {
if
(process_title) {
*len =
strlen
(process_title);
return
process_title;
}
*len =
0
;
return
NULL
;
}
//
Researched by Tim Becker and Michael Knight
//
http://blog.kuriositaet.de/?p=257
int
OS::GetMemory
(
size_t
*rss,
size_t
*vsize) {
struct
task_basic_info
t_info;
mach_msg_type_number_t
t_info_count =
TASK_BASIC_INFO_COUNT
;
int
r =
task_info
(
mach_task_self
(),
TASK_BASIC_INFO
,
(
task_info_t
)&t_info,
&t_info_count);
if
(r !=
KERN_SUCCESS
)
return
-
1
;
*rss = t_info.
resident_size
;
*vsize = t_info.
virtual_size
;
return
0
;
}
int
OS::GetExecutablePath
(
char
* buffer,
size_t
* size) {
uint32_t
usize = *size;
int
result =
_NSGetExecutablePath
(buffer, &usize);
if
(result)
return
result;
char
*path =
new
char
[
2
*
PATH_MAX
];
char
*fullpath =
realpath
(buffer, path);
if
(fullpath ==
NULL
) {
delete []
path;
return
-
1
;
}
strncpy
(buffer, fullpath, *size);
delete []
fullpath;
*size =
strlen
(buffer);
return
0
;
}
}
//
namespace node
Back
|
FazBrowse Home
|
New Git URL