removed script from kill group
This commit is contained in:
+13
-3
@@ -7,6 +7,7 @@
|
|||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
#include <termios.h>
|
||||||
|
|
||||||
|
|
||||||
#define DEFAULT_NUM_LEN 512
|
#define DEFAULT_NUM_LEN 512
|
||||||
@@ -276,6 +277,13 @@ int main(void)
|
|||||||
sigaction(SIGINT, &sa, NULL);
|
sigaction(SIGINT, &sa, NULL);
|
||||||
|
|
||||||
pid_t fork_pgid = getpgrp();
|
pid_t fork_pgid = getpgrp();
|
||||||
|
int owns_pgrp = 0;
|
||||||
|
if (!isatty(STDIN_FILENO) || tcgetpgrp(STDIN_FILENO) != fork_pgid) {
|
||||||
|
if (setpgid(0, 0) == 0) {
|
||||||
|
fork_pgid = getpgrp();
|
||||||
|
owns_pgrp = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
fprintf(csv, "timestamp,elapsed_s,load1,load5,load15,mem_total_kb,mem_available_kb,mem_used_kb,proc_count,thread_count_total,pid,cpu_pct,sys_cpu_pct,forks_per_sec,rss_kb,vsz_kb,stack_kb,heap_kb,proc_threads\n");
|
fprintf(csv, "timestamp,elapsed_s,load1,load5,load15,mem_total_kb,mem_available_kb,mem_used_kb,proc_count,thread_count_total,pid,cpu_pct,sys_cpu_pct,forks_per_sec,rss_kb,vsz_kb,stack_kb,heap_kb,proc_threads\n");
|
||||||
|
|
||||||
long count = 0;
|
long count = 0;
|
||||||
@@ -370,9 +378,11 @@ int main(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
signal(SIGTERM, SIG_IGN);
|
if (owns_pgrp) {
|
||||||
signal(SIGINT, SIG_IGN);
|
signal(SIGTERM, SIG_IGN);
|
||||||
killpg(fork_pgid, SIGTERM);
|
signal(SIGINT, SIG_IGN);
|
||||||
|
killpg(fork_pgid, SIGTERM);
|
||||||
|
}
|
||||||
|
|
||||||
fclose(csv);
|
fclose(csv);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user