summaryrefslogtreecommitdiffstats
path: root/util/shmctl.c
diff options
context:
space:
mode:
authorin2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2002-04-10 04:10:31 +0800
committerin2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2002-04-10 04:10:31 +0800
commitbee171e6635b88aa65c696f4ff2665cddf886e48 (patch)
treea44eb6738c799bc4ec392c0f10f004374ca8a34a /util/shmctl.c
parent1334ecd6b1bc494e0ddc18055b650d1f31334842 (diff)
downloadpttbbs-bee171e6635b88aa65c696f4ff2665cddf886e48.tar
pttbbs-bee171e6635b88aa65c696f4ff2665cddf886e48.tar.gz
pttbbs-bee171e6635b88aa65c696f4ff2665cddf886e48.tar.bz2
pttbbs-bee171e6635b88aa65c696f4ff2665cddf886e48.tar.lz
pttbbs-bee171e6635b88aa65c696f4ff2665cddf886e48.tar.xz
pttbbs-bee171e6635b88aa65c696f4ff2665cddf886e48.tar.zst
pttbbs-bee171e6635b88aa65c696f4ff2665cddf886e48.zip
remove pickup_t:idle, clean of idle timeout to shmctl
git-svn-id: http://opensvn.csie.org/pttbbs/pttbbs/trunk/pttbbs@92 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'util/shmctl.c')
-rw-r--r--util/shmctl.c33
1 files changed, 17 insertions, 16 deletions
diff --git a/util/shmctl.c b/util/shmctl.c
index 13b97d14..0d8a3589 100644
--- a/util/shmctl.c
+++ b/util/shmctl.c
@@ -5,7 +5,6 @@
#include <ctype.h>
#include <signal.h>
#include <sys/types.h>
-#include <sys/stat.h>
#include <sys/shm.h>
#include "config.h"
#include "pttstruct.h"
@@ -17,29 +16,31 @@ extern struct utmpfile_t *utmpshm;
int utmpfix(int argc, char **argv)
{
int i;
+ time_t now;
char buf[1024], *clean;
- struct stat st;
- if( utmpshm->busystate ){
- puts("utmpshm is busy");
- return 0;
- }
+
+ time(&now);
+ for( i = 0 ; i < 5 ; ++i )
+ if( !utmpshm->busystate )
+ break;
+ else{
+ puts("utmpshm is busy....");
+ sleep(1);
+ }
utmpshm->busystate = 1;
for( i = 0 ; i < USHM_SIZE ; ++i )
if( utmpshm->uinfo[i].pid ){
clean = NULL;
if( !isalpha(utmpshm->uinfo[i].userid[0]) )
clean = "userid error";
+ else if( now - utmpshm->uinfo[i].lastact > 1800 )
+ clean = "timeout";
else{
- sprintf(buf, "/proc/%d", utmpshm->uinfo[i].pid);
- if( stat(buf, &st) < 0 )
- clean = "process not exist";
- else{
- sprintf(buf, "home/%c/%s",
- utmpshm->uinfo[i].userid[0],
- utmpshm->uinfo[i].userid);
- if( stat(buf, &st) < 0 )
- clean = "user not exist";
- }
+ sprintf(buf, "home/%c/%s",
+ utmpshm->uinfo[i].userid[0],
+ utmpshm->uinfo[i].userid);
+ if( access(buf, 0) < 0 )
+ clean = "user not exist";
}
if( clean ){