Rev 7673 | Go to most recent revision | Details | 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 | |||
18 | /* Only miscellaneous cleanup routines remain. |
||
19 | * The regular session cleaner has been moved to wimslogd. */ |
||
20 | |||
21 | void cleantmpdir(void) |
||
22 | { |
||
23 | char buf[MAX_LINELEN+1], *p1, *p2; |
||
24 | |||
25 | accessfile(buf,"r","%s/exec.pid",tmp_dir); |
||
26 | for(p1=find_word_start(buf); *p1; p1=find_word_start(p2)) { |
||
27 | p2=find_word_end(p1); if(*p2) *p2++=0; |
||
28 | kill(atoi(p1),SIGKILL); |
||
29 | } |
||
30 | if(strstr(tmp_dir,"sessions/")!=NULL && |
||
31 | (strstr(tmp_debug,"yes")==NULL || checkhost(manager_site)<1)) { |
||
32 | if(remove_tree(tmp_dir)) { |
||
33 | call_ssh("bin/ch..root cleantmpdir 2>/dev/null"); |
||
34 | remove_tree(tmp_dir); |
||
35 | } |
||
36 | } |
||
37 | else { |
||
38 | mkfname(buf,"%s/exec.pid",tmp_dir); |
||
39 | unlink(buf); |
||
40 | if(strstr(tmp_dir,"sessions/")!=NULL) { |
||
41 | chmod(tmp_dir,S_IRUSR|S_IWUSR|S_IXUSR); |
||
42 | } |
||
43 | } |
||
44 | } |
||
45 | |||
46 | /* remove pid tag */ |
||
47 | void delete_pid(void) |
||
48 | { |
||
49 | char buf[MAX_FNAME+1],pbuf[32]; |
||
50 | |||
51 | flushlog(); flushoutput(); |
||
52 | if(robot_access || *session_prefix==0) return; |
||
53 | cleantmpdir(); |
||
54 | mkfname(buf,"%s/.pid",s2_prefix); |
||
55 | readfile(buf,pbuf,sizeof(pbuf)); |
||
56 | if(pbuf[0] && strcmp(pbuf,pidbuf)==0) unlink(buf); |
||
57 | flushlog(); |
||
58 | } |
||
59 |