diff options
author | in2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2004-01-01 21:33:52 +0800 |
---|---|---|
committer | in2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2004-01-01 21:33:52 +0800 |
commit | ef70ce06c3749d921b1b7dd657907659bf428f54 (patch) | |
tree | 27c927301ca1d313bb65d64a28f755763d00c7fb | |
parent | 030c46c0432b7fa6b025b7cefbefe4fbab325092 (diff) | |
download | pttbbs-ef70ce06c3749d921b1b7dd657907659bf428f54.tar pttbbs-ef70ce06c3749d921b1b7dd657907659bf428f54.tar.gz pttbbs-ef70ce06c3749d921b1b7dd657907659bf428f54.tar.bz2 pttbbs-ef70ce06c3749d921b1b7dd657907659bf428f54.tar.lz pttbbs-ef70ce06c3749d921b1b7dd657907659bf428f54.tar.xz pttbbs-ef70ce06c3749d921b1b7dd657907659bf428f54.tar.zst pttbbs-ef70ce06c3749d921b1b7dd657907659bf428f54.zip |
warning free
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@1443 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r-- | util/shmctl.c | 116 |
1 files changed, 58 insertions, 58 deletions
diff --git a/util/shmctl.c b/util/shmctl.c index 772df087..8c3435ca 100644 --- a/util/shmctl.c +++ b/util/shmctl.c @@ -493,6 +493,64 @@ int bBMC(int argc, char **argv) return 0; } +#ifdef NOKILLWATERBALL +int nkwbd(int argc, char **argv) +{ + int ch, sleeptime = 120, timeout = 120; + while( (ch = getopt(argc, argv, "s:t:h")) != -1 ) + switch( ch ){ + case 's': + if( (sleeptime = atoi(optarg)) < 10 ){ + fprintf(stderr, "sleeptime < 10? set to 60"); + sleeptime = 60; + } + break; + + case 't': + if( (timeout = atoi(optarg)) < 10 ){ + fprintf(stderr, "timeout < 10? set to 60"); + timeout = 60; + } + break; + + default: + fprintf(stderr, "usage: shmctl nkwbd [-s sleeptime] [-t timeout]\n"); + return 0; + } + + switch( fork() ){ + case -1: + perror("fork()"); + return 0; + break; + + case 0: /* child */ + while( 1 ){ + int i; + time_t t = SHM->GV2.e.now - timeout; + + printf("scanning\n"); + for( i = 0 ; i < MAX_ACTIVE ; ++i ) + if( SHM->uinfo[i].pid && + SHM->uinfo[i].wbtime && + SHM->uinfo[i].wbtime < t ){ + printf("kill: %d\n", SHM->uinfo[i].pid); + kill(SHM->uinfo[i].pid, SIGUSR2); + SHM->uinfo[i].wbtime = 0; /* race */ + } + printf("scanned\n"); + sleep(sleeptime); + } + break; + + default: /* parent */ + fprintf(stderr, "nkwbd\n"); + return 0; + } + return 0; +} +#endif + int SHMinit(int argc, char **argv) { int ch; @@ -617,64 +675,6 @@ int usermode(int argc, char **argv) return 0; } -#ifdef NOKILLWATERBALL -int nkwbd(int argc, char **argv) -{ - int ch, sleeptime = 120, timeout = 120; - while( (ch = getopt(argc, argv, "s:t:h")) != -1 ) - switch( ch ){ - case 's': - if( (sleeptime = atoi(optarg)) < 10 ){ - fprintf(stderr, "sleeptime < 10? set to 60"); - sleeptime = 60; - } - break; - - case 't': - if( (timeout = atoi(optarg)) < 10 ){ - fprintf(stderr, "timeout < 10? set to 60"); - timeout = 60; - } - break; - - default: - fprintf(stderr, "usage: shmctl nkwbd [-s sleeptime] [-t timeout]\n"); - return 0; - } - - switch( fork() ){ - case -1: - perror("fork()"); - return 0; - break; - - case 0: /* child */ - while( 1 ){ - int i; - time_t t = SHM->GV2.e.now - timeout; - - printf("scanning\n"); - for( i = 0 ; i < MAX_ACTIVE ; ++i ) - if( SHM->uinfo[i].pid && - SHM->uinfo[i].wbtime && - SHM->uinfo[i].wbtime < t ){ - printf("kill: %d\n", SHM->uinfo[i].pid); - kill(SHM->uinfo[i].pid, SIGUSR2); - SHM->uinfo[i].wbtime = 0; /* race */ - } - printf("scanned\n"); - sleep(sleeptime); - } - break; - - default: /* parent */ - fprintf(stderr, "nkwbd\n"); - return 0; - } - return 0; -} -#endif - struct { int (*func)(int, char **); char *cmd, *descript; |