1
0
mirror of https://github.com/GOSTSec/sgminer synced 2025-02-05 11:34:16 +00:00

When using '-m' on linux, send the forked process a SIGTERM on exit

This commit is contained in:
Kano 2012-03-30 14:57:18 +11:00
parent 3fa3f60b74
commit f9af5acf13

View File

@ -221,6 +221,7 @@ static int include_count = 0;
#if defined(unix)
static char *opt_stderr_cmd = NULL;
static int forkpid = 0;
#endif // defined(unix)
bool ping = true;
@ -4121,6 +4122,13 @@ void quit(int status, const char *format, ...)
fprintf(stderr, "\n");
fflush(stderr);
#if defined(unix)
if (forkpid > 0) {
kill(forkpid, SIGTERM);
forkpid = 0;
}
#endif
exit(status);
}
@ -4265,14 +4273,14 @@ out:
}
// Fork a child process
r = fork();
if (r<0) {
forkpid = fork();
if (forkpid<0) {
perror("fork - failed to fork child process for --monitor");
exit(1);
}
// Child: launch monitor command
if (0==r) {
if (0==forkpid) {
// Make stdin read end of pipe
r = dup2(pfd[0], 0);
if (r<0) {
@ -4839,5 +4847,12 @@ begin_bench:
free(block);
}
#if defined(unix)
if (forkpid > 0) {
kill(forkpid, SIGTERM);
forkpid = 0;
}
#endif
return 0;
}