Back to index

nordugrid-arc-nox  1.1.0~rc6
gm_kick.cpp
Go to the documentation of this file.
00001 #ifdef HAVE_CONFIG_H
00002 #include <config.h>
00003 #endif
00004 
00005 #include <sys/types.h>
00006 #include <sys/stat.h>
00007 #include <unistd.h>
00008 
00009 #include "jobs/users.h"
00010 #include "jobs/commfifo.h"
00011 
00012 
00013 int main(int argc,char* argv[]) {
00014   // All input arguments are supposed to contain path to status files
00015   for(int n = 1;n<argc;n++) {
00016     struct stat st;
00017     if(lstat(argv[n],&st) != 0) continue;
00018     if(!S_ISREG(st.st_mode)) continue;
00019     JobUser user(st.st_uid);
00020     if(!user.is_valid()) continue;
00021     std::string path = argv[n];
00022     if(path[0] != '/') {
00023       char buf[BUFSIZ];
00024       if(getcwd(buf,BUFSIZ) != NULL) path=std::string(buf)+"/"+path;
00025     };
00026     std::string::size_type l = path.rfind('/');
00027     if(l == std::string::npos) continue;
00028     path.resize(l); 
00029     user.SetControlDir(path);
00030     SignalFIFO(user);
00031   };
00032   return 0;
00033 }
00034