Back to index

wims  3.65+svn20090927
cleaning.c
Go to the documentation of this file.
00001 /*    Copyright (C) 1998-2003 XIAO, Gang of Universite de Nice - Sophia Antipolis
00002  *
00003  *  This program is free software; you can redistribute it and/or modify
00004  *  it under the terms of the GNU General Public License as published by
00005  *  the Free Software Foundation; either version 2 of the License, or
00006  *  (at your option) any later version.
00007  *
00008  *  This program is distributed in the hope that it will be useful,
00009  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00010  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00011  *  GNU General Public License for more details.
00012  *
00013  *  You should have received a copy of the GNU General Public License
00014  *  along with this program; if not, write to the Free Software
00015  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00016  */
00017 
00018        /* Only miscellaneous cleanup routines remain.
00019         * The regular session cleaner has been moved to wimslogd. */
00020 
00021 void cleantmpdir(void)
00022 {
00023     char buf[MAX_LINELEN+1], *p1, *p2;
00024     
00025     accessfile(buf,"r","%s/exec.pid",tmp_dir);
00026     for(p1=find_word_start(buf); *p1; p1=find_word_start(p2)) {
00027        p2=find_word_end(p1); if(*p2) *p2++=0;
00028        kill(atoi(p1),SIGKILL);
00029     }
00030     if(strstr(tmp_dir,"sessions/")!=NULL && 
00031        (strstr(tmp_debug,"yes")==NULL || checkhost(manager_site)<1)) {
00032        if(remove_tree(tmp_dir)) {
00033            call_ssh("bin/ch..root cleantmpdir 2>/dev/null");
00034            remove_tree(tmp_dir);
00035        }
00036     }
00037     else {
00038        mkfname(buf,"%s/exec.pid",tmp_dir);
00039        unlink(buf);
00040        if(strstr(tmp_dir,"sessions/")!=NULL) {
00041            chmod(tmp_dir,S_IRUSR|S_IWUSR|S_IXUSR);
00042        }
00043     }
00044 }
00045 
00046        /* remove pid tag */
00047 void delete_pid(void)
00048 {
00049     char buf[MAX_FNAME+1],pbuf[32];
00050 
00051     flushlog(); flushoutput();
00052     if(robot_access || *session_prefix==0) return;
00053     cleantmpdir();
00054     mkfname(buf,"%s/.pid",s2_prefix);
00055     readfile(buf,pbuf,sizeof(pbuf));
00056     if(pbuf[0] && strcmp(pbuf,pidbuf)==0) unlink(buf);
00057     flushlog();
00058 }
00059