Skip to content

Commit 34732ff

Browse files
committed
fix pid size
1 parent 9873bc9 commit 34732ff

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

src/stdlib_system_subprocess.c

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -129,14 +129,16 @@ void process_create_windows(const char* cmd, const char* stdin_stream,
129129
}
130130

131131
// Query process state on a Windows system
132-
void process_query_status_windows(int pid, bool wait, bool* is_running, int* exit_code)
132+
void process_query_status_windows(stdlib_pid pid, bool wait, bool* is_running, int* exit_code)
133133
{
134134
int wait_code;
135135
HANDLE hProcess;
136-
DWORD dwExitCode;
136+
DWORD dwExitCode,dwPid;
137+
138+
dwPid = (DWORD) pid;
137139

138140
// Open the process with the appropriate access rights
139-
hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | SYNCHRONIZE, FALSE, pid);
141+
hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | SYNCHRONIZE, FALSE, dwPid);
140142

141143
// Error opening the process, likely pid does not exist
142144
if (hProcess == NULL) {
@@ -179,11 +181,14 @@ void process_query_status_windows(int pid, bool wait, bool* is_running, int* exi
179181
// Kill a process on Windows by sending a PROCESS_TERMINATE signal.
180182
// Return true if the operation succeeded, or false if it failed (process does not
181183
// exist anymore, or we may not have the rights to kill the process).
182-
bool process_kill_windows(int pid) {
184+
bool process_kill_windows(stdlib_pid pid) {
183185
HANDLE hProcess;
186+
DWORD dwPid;
187+
188+
dwPid = (DWORD) pid;
184189

185190
// Open the process with terminate rights
186-
hProcess = OpenProcess(PROCESS_TERMINATE, FALSE, pid);
191+
hProcess = OpenProcess(PROCESS_TERMINATE, FALSE, dwPid);
187192

188193
if (hProcess == NULL) {
189194
// Failed to open the process; return false
@@ -208,7 +213,7 @@ bool process_kill_windows(int pid) {
208213
/////////////////////////////////////////////////////////////////////////////////////
209214
// Unix-specific code
210215
/////////////////////////////////////////////////////////////////////////////////////
211-
void process_query_status_unix(int pid, bool wait, bool* is_running, int* exit_code)
216+
void process_query_status_unix(stdlib_pid pid, bool wait, bool* is_running, int* exit_code)
212217
{
213218
int status;
214219
int wait_code;
@@ -249,7 +254,7 @@ void process_query_status_unix(int pid, bool wait, bool* is_running, int* exit_c
249254

250255
// Kill a process by sending a SIGKILL signal. Return .true. if succeeded, or false if not.
251256
// Killing process may fail due to unexistent process, or not enough rights to kill.
252-
bool process_kill_unix(int pid) {
257+
bool process_kill_unix(stdlib_pid pid) {
253258
// Send the SIGKILL signal to the process
254259
if (kill(pid, SIGKILL) == 0) {
255260
// Successfully sent the signal
@@ -292,7 +297,7 @@ void process_create(const char* cmd, const char* stdin_stream, const char* stdin
292297
}
293298

294299
// Cross-platform interface: query process state
295-
void process_query_status(int pid, bool wait, bool* is_running, int* exit_code)
300+
void process_query_status(stdlib_pid pid, bool wait, bool* is_running, int* exit_code)
296301
{
297302
#ifdef _WIN32
298303
process_query_status_windows(pid, wait, is_running, exit_code);
@@ -302,7 +307,7 @@ void process_query_status(int pid, bool wait, bool* is_running, int* exit_code)
302307
}
303308

304309
// Cross-platform interface: kill process by ID
305-
bool process_kill(int pid)
310+
bool process_kill(stdlib_pid pid)
306311
{
307312
#ifdef _WIN32
308313
return process_kill_windows(pid);

0 commit comments

Comments
 (0)