Subversion Repositories wimsdev

Rev

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

  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.  
  22. void cleantmpdir(void)
  23. {
  24.     char buf[MAX_LINELEN+1], *p1, *p2;
  25.  
  26.     accessfile(buf,"r","%s/exec.pid",tmp_dir);
  27.     for(p1=find_word_start(buf); *p1; p1=find_word_start(p2)) {
  28.      p2=find_word_end(p1); if(*p2) *p2++=0;
  29.      kill(atoi(p1),SIGKILL);
  30.     }
  31.     if(strstr(tmp_dir,"sessions/")!=NULL &&
  32.        (strstr(tmp_debug,"yes")==NULL || checkhost(manager_site)<1)) {
  33.      if(remove_tree(tmp_dir)) {
  34.          call_ssh("bin/ch..root cleantmpdir 2>/dev/null");
  35.          remove_tree(tmp_dir);
  36.      }
  37.     }
  38.     else {
  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.      }
  44.     }
  45. }
  46.  
  47. /* remove pid tag */
  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.  
  61.