Subversion Repositories wimsdev

Rev

Rev 8185 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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