Skip to content

Commit 0c4b69f

Browse files
committed
implemented send_signal in C
1 parent d724658 commit 0c4b69f

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/stdlib_system_subprocess.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,14 @@ bool process_kill_unix(stdlib_pid pid) {
284284
return false;
285285
}
286286

287+
// send signal to a process. returns true if success, else false.
288+
bool process_send_signal_unix(stdlib_pid pid, int signal) {
289+
if (kill(pid, signal) == 0) {
290+
return true;
291+
}
292+
293+
return false; // errors occurred
294+
}
287295

288296
// On UNIX systems: just fork a new process. The command line will be executed from Fortran.
289297
void process_create_posix(stdlib_pid* pid)
@@ -329,6 +337,17 @@ bool process_kill(stdlib_pid pid)
329337
#endif // _WIN32
330338
}
331339

340+
// Cross-platform interface: send signal to a process by ID
341+
// no-op on Windows
342+
bool process_send_signal(stdlib_pid pid, int signal)
343+
{
344+
#ifndef _WIN32
345+
return process_send_signal_unix(pid, signal);
346+
#else
347+
return false;
348+
#endif
349+
}
350+
332351
// Cross-platform interface: sleep(seconds)
333352
void process_wait(float seconds)
334353
{

0 commit comments

Comments
 (0)