mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
For c3c run and friends, pass SIGINT to child process on Linux (#2480)
This commit is contained in:
@@ -5,6 +5,8 @@
|
||||
|
||||
#if PLATFORM_POSIX
|
||||
#include <sys/wait.h>
|
||||
|
||||
pid_t cpid;
|
||||
#endif
|
||||
|
||||
#if PLATFORM_WINDOWS
|
||||
@@ -12,6 +14,13 @@
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#if defined(__linux__)
|
||||
void signal_to_subprocess(int sig)
|
||||
{
|
||||
kill(cpid, sig);
|
||||
}
|
||||
#endif
|
||||
|
||||
int run_subprocess(const char *name, const char **args)
|
||||
{
|
||||
#if PLATFORM_WINDOWS
|
||||
@@ -105,7 +114,7 @@ int run_subprocess(const char *name, const char **args)
|
||||
|
||||
return exit_status;
|
||||
#else
|
||||
pid_t cpid = fork();
|
||||
cpid = fork();
|
||||
if (cpid < 0)
|
||||
{
|
||||
eprintf("Could not fork child process %s: %s\n", name, strerror(errno));
|
||||
@@ -129,6 +138,9 @@ int run_subprocess(const char *name, const char **args)
|
||||
exit(0);
|
||||
}
|
||||
|
||||
#if defined(__linux__)
|
||||
signal(SIGINT, signal_to_subprocess);
|
||||
#endif
|
||||
for (;;)
|
||||
{
|
||||
int wstatus = 0;
|
||||
|
||||
Reference in New Issue
Block a user