Subversion Repositories wimsdev

Rev

Rev 7673 | Rev 8185 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
10 reyssat 1
/*    Copyright (C) 1998-2003 XIAO, Gang of Universite de Nice - Sophia Antipolis
2
 *
3
 *  This program is free software; you can redistribute it and/or modify
4
 *  it under the terms of the GNU General Public License as published by
5
 *  the Free Software Foundation; either version 2 of the License, or
6
 *  (at your option) any later version.
7
 *
8
 *  This program is distributed in the hope that it will be useful,
9
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
 *  GNU General Public License for more details.
12
 *
13
 *  You should have received a copy of the GNU General Public License
14
 *  along with this program; if not, write to the Free Software
15
 *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16
 */
17
 
7673 bpr 18
/* Only miscellaneous cleanup routines remain.
8155 bpr 19
 * The regular session cleaner has been moved to wimslogd.
20
 */
10 reyssat 21
 
22
void cleantmpdir(void)
23
{
24
    char buf[MAX_LINELEN+1], *p1, *p2;
7673 bpr 25
 
10 reyssat 26
    accessfile(buf,"r","%s/exec.pid",tmp_dir);
27
    for(p1=find_word_start(buf); *p1; p1=find_word_start(p2)) {
7673 bpr 28
     p2=find_word_end(p1); if(*p2) *p2++=0;
29
     kill(atoi(p1),SIGKILL);
10 reyssat 30
    }
7673 bpr 31
    if(strstr(tmp_dir,"sessions/")!=NULL &&
10 reyssat 32
       (strstr(tmp_debug,"yes")==NULL || checkhost(manager_site)<1)) {
7673 bpr 33
     if(remove_tree(tmp_dir)) {
34
         call_ssh("bin/ch..root cleantmpdir 2>/dev/null");
35
         remove_tree(tmp_dir);
36
     }
10 reyssat 37
    }
38
    else {
7673 bpr 39
     mkfname(buf,"%s/exec.pid",tmp_dir);
40
     unlink(buf);
41
     if(strstr(tmp_dir,"sessions/")!=NULL) {
42
         chmod(tmp_dir,S_IRUSR|S_IWUSR|S_IXUSR);
43
     }
10 reyssat 44
    }
45
}
46
 
7673 bpr 47
/* remove pid tag */
10 reyssat 48
void delete_pid(void)
49
{
50
    char buf[MAX_FNAME+1],pbuf[32];
51
 
52
    flushlog(); flushoutput();
53
    if(robot_access || *session_prefix==0) return;
54
    cleantmpdir();
55
    mkfname(buf,"%s/.pid",s2_prefix);
56
    readfile(buf,pbuf,sizeof(pbuf));
57
    if(pbuf[0] && strcmp(pbuf,pidbuf)==0) unlink(buf);
58
    flushlog();
59
}
60