mirror of
https://github.com/GOSTSec/sgminer
synced 2025-02-05 19:44:21 +00:00
When using '-m' on linux, send the forked process a SIGTERM on exit
This commit is contained in:
parent
3fa3f60b74
commit
f9af5acf13
21
cgminer.c
21
cgminer.c
@ -221,6 +221,7 @@ static int include_count = 0;
|
|||||||
|
|
||||||
#if defined(unix)
|
#if defined(unix)
|
||||||
static char *opt_stderr_cmd = NULL;
|
static char *opt_stderr_cmd = NULL;
|
||||||
|
static int forkpid = 0;
|
||||||
#endif // defined(unix)
|
#endif // defined(unix)
|
||||||
|
|
||||||
bool ping = true;
|
bool ping = true;
|
||||||
@ -4121,6 +4122,13 @@ void quit(int status, const char *format, ...)
|
|||||||
fprintf(stderr, "\n");
|
fprintf(stderr, "\n");
|
||||||
fflush(stderr);
|
fflush(stderr);
|
||||||
|
|
||||||
|
#if defined(unix)
|
||||||
|
if (forkpid > 0) {
|
||||||
|
kill(forkpid, SIGTERM);
|
||||||
|
forkpid = 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
exit(status);
|
exit(status);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4265,14 +4273,14 @@ out:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Fork a child process
|
// Fork a child process
|
||||||
r = fork();
|
forkpid = fork();
|
||||||
if (r<0) {
|
if (forkpid<0) {
|
||||||
perror("fork - failed to fork child process for --monitor");
|
perror("fork - failed to fork child process for --monitor");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Child: launch monitor command
|
// Child: launch monitor command
|
||||||
if (0==r) {
|
if (0==forkpid) {
|
||||||
// Make stdin read end of pipe
|
// Make stdin read end of pipe
|
||||||
r = dup2(pfd[0], 0);
|
r = dup2(pfd[0], 0);
|
||||||
if (r<0) {
|
if (r<0) {
|
||||||
@ -4839,5 +4847,12 @@ begin_bench:
|
|||||||
free(block);
|
free(block);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(unix)
|
||||||
|
if (forkpid > 0) {
|
||||||
|
kill(forkpid, SIGTERM);
|
||||||
|
forkpid = 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user