void readServerConfig(string& serverIPAddr) { string serverConfigFile = "serverConfig.txt"; checkFileExistence(serverConfigFile); ifstream serverConfig(serverConfigFile.c_str()); // read server's IP address getline(serverConfig,serverIPAddr); serverConfig.close(); }
/* * check if files being monitored still exist every 5sec * filenames given from argv[3] to argv[argc-1] * if the file does not exist anymore, the process group monitoring its words is killed */ void monitorExistence(char *argv[], __pid_t *pgrids, int argc){ if(DEBUG) printf("I am the existence monitor. My pid: %d. My ppid: %d\n", getpid(), getppid()); while(1){ sleep(5); int i=3; for(; i<argc; i++) //trying to open the files { int tmp = i-3; //tmp is the matching pid index at pgrid if(pgrids[tmp] != 0) { if(DEBUG) printf("Verifying existence of %s, that belongs with %d group\n", argv[i], pgrids[tmp]); if(checkFileExistence(argv[i]) == -1){ killOneProcessGroup(pgrids[tmp]); pgrids[tmp]=0; } } } } }