diff options
author | in2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2002-05-26 05:13:06 +0800 |
---|---|---|
committer | in2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2002-05-26 05:13:06 +0800 |
commit | 27f26b202e7a36223e142cc8a5984a49b3fe7235 (patch) | |
tree | 791a7d0e72ec99a60fe5014bf0853ba96297a6ba /util | |
parent | 28c35d3f035a1b2aabd15a2f6a034961b6e2f709 (diff) | |
download | pttbbs-27f26b202e7a36223e142cc8a5984a49b3fe7235.tar pttbbs-27f26b202e7a36223e142cc8a5984a49b3fe7235.tar.gz pttbbs-27f26b202e7a36223e142cc8a5984a49b3fe7235.tar.bz2 pttbbs-27f26b202e7a36223e142cc8a5984a49b3fe7235.tar.lz pttbbs-27f26b202e7a36223e142cc8a5984a49b3fe7235.tar.xz pttbbs-27f26b202e7a36223e142cc8a5984a49b3fe7235.tar.zst pttbbs-27f26b202e7a36223e142cc8a5984a49b3fe7235.zip |
stop, STOP
git-svn-id: http://opensvn.csie.org/pttbbs/pttbbs/trunk/pttbbs@238 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'util')
-rw-r--r-- | util/bbsctl.c | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/util/bbsctl.c b/util/bbsctl.c index b6a6388f..03a68689 100644 --- a/util/bbsctl.c +++ b/util/bbsctl.c @@ -72,6 +72,35 @@ int stopbbs(int argc, char **argv) DIR *dirp; struct dirent *de; FILE *fp; + char buf[512], fn[512]; + if( !(dirp = opendir("run")) ){ + perror("open " BBSHOME "/run"); + exit(0); + } + + while( (de = readdir(dirp)) ){ + if( strstr(de->d_name, "mbbsd") && strstr(de->d_name, "pid")){ + sprintf(fn, BBSHOME "/run/%s", de->d_name); + if( (fp = fopen(fn, "r")) != NULL ){ + if( fgets(buf, sizeof(buf), fp) != NULL ){ + printf("stopping listening-mbbsd at pid %5d\n", atoi(buf)); + kill(atoi(buf), 9); + } + fclose(fp); + unlink(fn); + } + } + } + + closedir(dirp); + return 0; +} + +int STOP(int argc, char **argv) +{ + DIR *dirp; + struct dirent *de; + FILE *fp; char buf[512]; if( !(dirp = opendir("/proc")) ){ perror("open /proc"); @@ -83,8 +112,8 @@ int stopbbs(int argc, char **argv) sprintf(buf, "/proc/%s/cmdline", de->d_name); if( (fp = fopen(buf, "r")) ){ if( fgets(buf, sizeof(buf), fp) != NULL ){ - if( strstr(buf, "mbbsd") && strstr(buf, "listening") ){ - kill(atoi(de->d_name), 9); + if( strstr(buf, "mbbsd") ){ + kill(atoi(de->d_name), 1); printf("stopping mbbsd at pid %5d\n", atoi(de->d_name)); } @@ -169,6 +198,7 @@ struct { {bbsadm, "bbsadm", "switch to user: bbsadm"}, {bbstest, "test", "run ./mbbsd as bbsadm"}, {Xipcrm, "ipcrm", "ipcrm all msg, shm, sem"}, + {STOP, "STOP", "killall ALL mbbsd"}, {NULL, NULL, NULL} }; int main(int argc, char **argv) |