"Fossies" - the Fresh Open Source Software Archive

Member "sysmask-1.08/smkdproc.c" (5 May 2005, 2227 Bytes) of package /linux/misc/old/sysmask-1.08.tgz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "smkdproc.c" see the Fossies "Dox" file reference documentation.

    1 /*    Copyright (C) 2005 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     /* smkd process bookkeeping. */
   19 
   20 struct {
   21     long pid;
   22     int opt;        /* type of kill */
   23     int start_time; /* uniq identifier for process */
   24     time_t kill_time;
   25 } killtab[KILL_MAX];
   26 
   27 int killcnt;
   28 
   29 void addkill(int delay,int type)
   30 {
   31     int i;
   32     long id;
   33     if(type==0) {
   34     id=request.pid;
   35     for(i=0;i<killcnt;i++) {
   36         if(killtab[i].pid==id && !killtab[i].opt) {
   37         if(killtab[i].start_time!=request.start_time) {
   38             killtab[i].start_time=request.start_time;
   39             killtab[i].kill_time=now+delay;
   40             return;
   41         }
   42         if(killtab[i].kill_time>now+delay)
   43           killtab[i].kill_time=now+delay;
   44         return;
   45         }
   46     }
   47     }
   48     else {
   49     id=ans.killid=killid++;
   50     for(i=0;i<killcnt;i++) {
   51         if(killtab[i].pid==id && killtab[i].opt) {
   52         if(killtab[i].kill_time>now+delay)
   53           killtab[i].kill_time=now+delay;
   54         return;
   55         }
   56     }
   57     }
   58     if(i>=killcnt && killcnt<KILL_MAX) {
   59     killtab[i].pid=id;
   60     killtab[i].opt=type;
   61     killtab[i].start_time=request.start_time;
   62     killtab[i].kill_time=ans.rlim[SMK_RLIM_TIMEOUT]=now+delay;
   63     killcnt++;
   64     }
   65 }
   66 
   67 void checkkill(void)
   68 {
   69     int i;
   70     for(i=0;i<killcnt;i++) {
   71     if(killtab[i].kill_time>=now) continue;
   72     memset(&ans,0,sizeof(ans));
   73     ans.ind=SMKD_ANS_KILL;
   74     ans.opt=killtab[i].opt;
   75     ans.smk.active.m1=killtab[i].pid;
   76     ans.smk.active.m2=killtab[i].start_time;
   77     sysmask(SMK_SMKDREP,&ans,sizeof(ans));
   78     memmove(&killtab[i],&killtab[i+1],(killcnt-i-1)*sizeof(killtab[0]));
   79     killcnt--;i--;
   80     }
   81 }
   82