diff options
author | in2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2004-05-02 11:07:03 +0800 |
---|---|---|
committer | in2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2004-05-02 11:07:03 +0800 |
commit | c2b2860276b8fd1976373bb776f784689af98ea1 (patch) | |
tree | 7479bab60cd7b7d8d38c553a44e08ecad55dafab /util/killdeadbbs.c | |
parent | dd37dc8252cf8bd0fef546c13514513126c1458e (diff) | |
download | pttbbs-c2b2860276b8fd1976373bb776f784689af98ea1.tar pttbbs-c2b2860276b8fd1976373bb776f784689af98ea1.tar.gz pttbbs-c2b2860276b8fd1976373bb776f784689af98ea1.tar.bz2 pttbbs-c2b2860276b8fd1976373bb776f784689af98ea1.tar.lz pttbbs-c2b2860276b8fd1976373bb776f784689af98ea1.tar.xz pttbbs-c2b2860276b8fd1976373bb776f784689af98ea1.tar.zst pttbbs-c2b2860276b8fd1976373bb776f784689af98ea1.zip |
remove unused programs
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@1916 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'util/killdeadbbs.c')
-rw-r--r-- | util/killdeadbbs.c | 56 |
1 files changed, 0 insertions, 56 deletions
diff --git a/util/killdeadbbs.c b/util/killdeadbbs.c deleted file mode 100644 index 0c83fe29..00000000 --- a/util/killdeadbbs.c +++ /dev/null @@ -1,56 +0,0 @@ -#ifndef FreeBSD -int main(int argc, char **argv) -{ - puts("this program is only for FreeBSD"); -} -#else -#include <err.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <unistd.h> -#include <signal.h> -#include <kvm.h> -#include <fcntl.h> -#include <limits.h> -#include <sys/param.h> -#include <sys/sysctl.h> -#include <sys/user.h> -#include "config.h" // for BBSUID - -int main(int argc, char **argv) -{ - kvm_t *kd; - struct kinfo_proc *kp; - char errbuf[_POSIX2_LINE_MAX]; - int nentries, i, npids; - pid_t pids[8192]; - kd = kvm_openfiles("/dev/null", "/dev/null", NULL, O_RDONLY, errbuf); - if( kd == NULL ) - errx(1, "%s", errbuf); - - if ((kp = kvm_getprocs(kd, KERN_PROC_UID, BBSUID, &nentries)) == 0 || - nentries < 0) - errx(1, "%s", kvm_geterr(kd)); - - for( npids = 0, i = nentries ; --i >= 0 ; ++kp ){ - if( strncmp(kp->ki_comm, "mbbsd", 5) == 0 ){ - if( kp->ki_runtime > (60 * 1000000) ){ // 60 secs - kill(kp->ki_pid, 1); - pids[npids++] = kp->ki_pid; - printf("%d\n", kp->ki_pid); - } - } - } - - if( npids != 0 ){ - sleep(2); - while( --npids >= 0 ) - kill(pids[npids], 9); - } - - kvm_close(kd); - return 0; -} - -#endif |