Browse Source

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

nfactor-troky
Kano 13 years ago
parent
commit
f9af5acf13
  1. 21
      cgminer.c

21
cgminer.c

@ -221,6 +221,7 @@ static int include_count = 0; @@ -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, ...) @@ -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: @@ -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: @@ -4839,5 +4847,12 @@ begin_bench:
free(block);
}
#if defined(unix)
if (forkpid > 0) {
kill(forkpid, SIGTERM);
forkpid = 0;
}
#endif
return 0;
}

Loading…
Cancel
Save