Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 40acda2

Browse filesBrowse files
cjihrigMylesBorins
authored andcommitted
src: use uv_os_getpid() to get process id
This commit uses the new uv_os_getpid() method to retrieve the current process id. PR-URL: #17415 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Jon Moss <me@jonathanmoss.me> Reviewed-By: Khaidi Chu <i@2333.moe>
1 parent 259f2d3 commit 40acda2
Copy full SHA for 40acda2

File tree

Expand file treeCollapse file tree

5 files changed

+6
-23
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

5 files changed

+6
-23
lines changed
Open diff view settings
Collapse file

‎src/env.cc‎

Copy file name to clipboardExpand all lines: src/env.cc
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ void Environment::PrintSyncTrace() const {
177177
StackTrace::CurrentStackTrace(isolate(), 10, StackTrace::kDetailed);
178178

179179
fprintf(stderr, "(node:%u) WARNING: Detected use of sync API\n",
180-
GetProcessId());
180+
uv_os_getpid());
181181

182182
for (int i = 0; i < stack->GetFrameCount() - 1; i++) {
183183
Local<StackFrame> stack_frame = stack->GetFrame(i);
Collapse file

‎src/inspector_agent.cc‎

Copy file name to clipboardExpand all lines: src/inspector_agent.cc
+2-3Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ static int StartDebugSignalHandler() {
109109
CHECK_EQ(0, pthread_attr_destroy(&attr));
110110
if (err != 0) {
111111
fprintf(stderr, "node[%u]: pthread_create: %s\n",
112-
GetProcessId(), strerror(err));
112+
uv_os_getpid(), strerror(err));
113113
fflush(stderr);
114114
// Leave SIGUSR1 blocked. We don't install a signal handler,
115115
// receiving the signal would terminate the process.
@@ -144,7 +144,7 @@ static int StartDebugSignalHandler() {
144144
DWORD pid;
145145
LPTHREAD_START_ROUTINE* handler;
146146

147-
pid = GetCurrentProcessId();
147+
pid = uv_os_getpid();
148148

149149
if (GetDebugSignalHandlerMappingName(pid,
150150
mapping_name,
@@ -692,4 +692,3 @@ bool Agent::IsWaitingForConnect() {
692692

693693
} // namespace inspector
694694
} // namespace node
695-
Collapse file

‎src/node.cc‎

Copy file name to clipboardExpand all lines: src/node.cc
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3465,7 +3465,7 @@ void SetupProcessObject(Environment* env,
34653465
process->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "env"), process_env);
34663466

34673467
READONLY_PROPERTY(process, "pid",
3468-
Integer::New(env->isolate(), GetProcessId()));
3468+
Integer::New(env->isolate(), uv_os_getpid()));
34693469
READONLY_PROPERTY(process, "features", GetFeatures(env));
34703470

34713471
CHECK(process->SetAccessor(env->context(),
Collapse file

‎src/node_internals.h‎

Copy file name to clipboardExpand all lines: src/node_internals.h
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,6 @@ void RegisterSignalHandler(int signal,
248248
bool reset_handler = false);
249249
#endif
250250

251-
uint32_t GetProcessId();
252251
bool SafeGetenv(const char* key, std::string* text);
253252

254253
std::string GetHumanReadableProcessName();
Collapse file

‎src/util.cc‎

Copy file name to clipboardExpand all lines: src/util.cc
+2-17Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,9 @@
2222
#include "string_bytes.h"
2323
#include "node_buffer.h"
2424
#include "node_internals.h"
25+
#include "uv.h"
2526
#include <stdio.h>
2627

27-
#ifdef __POSIX__
28-
#include <unistd.h> // getpid()
29-
#endif
30-
31-
#ifdef _MSC_VER
32-
#include <windows.h> // GetCurrentProcessId()
33-
#endif
34-
3528
namespace node {
3629

3730
using v8::Isolate;
@@ -122,15 +115,7 @@ std::string GetHumanReadableProcessName() {
122115
void GetHumanReadableProcessName(char (*name)[1024]) {
123116
char title[1024] = "Node.js";
124117
uv_get_process_title(title, sizeof(title));
125-
snprintf(*name, sizeof(*name), "%s[%u]", title, GetProcessId());
126-
}
127-
128-
uint32_t GetProcessId() {
129-
#ifdef _WIN32
130-
return GetCurrentProcessId();
131-
#else
132-
return getpid();
133-
#endif
118+
snprintf(*name, sizeof(*name), "%s[%u]", title, uv_os_getpid());
134119
}
135120

136121
} // namespace node

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.