Package: cpulimit Version: 1.1-12 Severity: normal
Each time cpulimit finds a process to limit, it does a goto past the call to closedir(). Assuming I'm using reportbug correctly, here's a patch to plug that leak. Regards //Johan -- System Information: Debian Release: squeeze/sid APT prefers testing APT policy: (990, 'testing') Architecture: i386 (i686) Kernel: Linux 2.6.30-2-686 (SMP w/2 CPU cores) Locale: LANG=sv_SE.UTF-8, LC_CTYPE=sv_SE.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/bash Versions of packages cpulimit depends on: ii libc6 2.10.2-2 GNU C Library: Shared libraries cpulimit recommends no packages. cpulimit suggests no packages. -- no debconf information
--- nej/cpulimit-1.1/cpulimit.c 2010-01-09 23:22:49.000000000 +0100 +++ hej/cpulimit-1.1/cpulimit.c 2010-01-09 23:18:13.000000000 +0100 @@ -98,6 +98,10 @@ //pid detected if (kill(pid,SIGSTOP)==0 && kill(pid,SIGCONT)==0) { //process is ok! + if (closedir(dip) == -1) { + perror("closedir"); + return -1; + } goto done; } else { @@ -188,6 +192,10 @@ if (found==1) { if (kill(pid,SIGSTOP)==0 && kill(pid,SIGCONT)==0) { //process is ok! + if (closedir(dip) == -1) { + perror("closedir"); + return -1; + } goto done; } else { @@ -509,7 +517,7 @@ fprintf(stderr,"Process %d dead!\n",pid); if (lazy) exit(2); //wait until our process appears - goto wait_for_process; + goto wait_for_process; } //cpu actual usage of process (range 0-1) @@ -550,7 +558,7 @@ } clock_gettime(CLOCK_REALTIME,&startwork); - nanosleep(&twork,NULL); //now process is working + nanosleep(&twork,NULL); //now process is working clock_gettime(CLOCK_REALTIME,&endwork); workingtime=timediff(&endwork,&startwork);