Subversion Repositories wimsdev

Rev

Rev 8185 | 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
 
8185 bpr 22
#include "wims.h"
23
 
10 reyssat 24
void cleantmpdir(void)
25
{
12244 bpr 26
  char buf[MAX_LINELEN+1], *p1, *p2;
7673 bpr 27
 
12244 bpr 28
  accessfile(buf,"r","%s/exec.pid",tmp_dir);
29
  for(p1=find_word_start(buf); *p1; p1=find_word_start(p2)) {
30
    p2=find_word_end(p1); if(*p2) *p2++=0;
31
    kill(atoi(p1),SIGKILL);
32
  }
33
  if(strstr(tmp_dir,"sessions/")!=NULL &&
34
     (strstr(tmp_debug,"yes")==NULL || checkhost(manager_site)<1)) {
35
    if(remove_tree(tmp_dir)) {
36
      call_ssh("bin/ch..root cleantmpdir 2>/dev/null");
37
      remove_tree(tmp_dir);
10 reyssat 38
    }
12244 bpr 39
  }
40
  else {
41
    mkfname(buf,"%s/exec.pid",tmp_dir);
42
    unlink(buf);
43
    if(strstr(tmp_dir,"sessions/")!=NULL) {
44
      chmod(tmp_dir,S_IRUSR|S_IWUSR|S_IXUSR);
10 reyssat 45
    }
12244 bpr 46
  }
10 reyssat 47
}
48
 
7673 bpr 49
/* remove pid tag */
10 reyssat 50
void delete_pid(void)
51
{
12244 bpr 52
  char buf[MAX_FNAME+1],pbuf[32];
10 reyssat 53
 
12244 bpr 54
  flushlog(); flushoutput();
55
  if(robot_access || *session_prefix==0) return;
56
  cleantmpdir();
57
  mkfname(buf,"%s/.pid",s2_prefix);
58
  readfile(buf,pbuf,sizeof(pbuf));
59
  if(pbuf[0] && strcmp(pbuf,pidbuf)==0) unlink(buf);
60
  flushlog();
10 reyssat 61
}