aboutsummaryrefslogtreecommitdiffstats
path: root/src/process_group.c
diff options
context:
space:
mode:
authorAngelo Marletta <angelo.marletta@gmail.com>2012-06-30 05:44:13 -0700
committerAngelo Marletta <angelo.marletta@gmail.com>2012-06-30 05:44:13 -0700
commit2449f7c1c8cb4de126da03322025c770381b6af5 (patch)
tree85252d613a6c44f520350e6b9af0d5090fb47d50 /src/process_group.c
parentd7373dde5dde22945524d09e2c3f7f1a8290c6b9 (diff)
parent1d7438185d0ac55a49e9adb6f719ef28e5501e0d (diff)
downloadcpulimit-2449f7c1c8cb4de126da03322025c770381b6af5.tar.gz
Merge pull request #5 from opsengine/develop
Fix issue #4
Diffstat (limited to 'src/process_group.c')
-rw-r--r--src/process_group.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/process_group.c b/src/process_group.c
index 671dd73..cb84deb 100644
--- a/src/process_group.c
+++ b/src/process_group.c
@@ -172,7 +172,7 @@ void update_process_group(struct process_group *pgroup)
// struct timeval t;
// gettimeofday(&t, NULL);
// printf("T=%ld.%ld PID=%d PPID=%d START=%d CPUTIME=%d\n", t.tv_sec, t.tv_usec, tmp_process.pid, tmp_process.ppid, tmp_process.starttime, tmp_process.cputime);
- int hashkey = pid_hashfn(tmp_process.pid + tmp_process.starttime);
+ int hashkey = pid_hashfn(tmp_process.pid);
if (pgroup->proctable[hashkey] == NULL)
{
//empty bucket
@@ -222,3 +222,13 @@ void update_process_group(struct process_group *pgroup)
if (dt < MIN_DT) return;
pgroup->last_update = now;
}
+
+int remove_process(struct process_group *pgroup, int pid)
+{
+ int hashkey = pid_hashfn(pid);
+ if (pgroup->proctable[hashkey] == NULL) return 1; //nothing to delete
+ struct list_node *node = (struct list_node*)locate_node(pgroup->proctable[hashkey], &pid);
+ if (node == NULL) return 2;
+ delete_node(pgroup->proctable[hashkey], node);
+ return 0;
+}
Un proyecto texto-plano.xyz