/* Remove the job task cpuset directory after first removing shepherd sub-directories. */ bool remove_job_cpuset(u_long32 job, u_long32 task) { #if ! __linux__ return true; #else /* using non-portable dirent-isms */ char dirpath[SGE_PATH_MAX]; DIR *dir; struct dirent *dent; DENTER(TOP_LAYER, "remove_job_cpuset"); snprintf(dirpath, sizeof dirpath, "%s/"sge_u32"."sge_u32, cgroup_dir(cg_cpuset), job, task); INFO((SGE_EVENT, "removing task cpuset "SFN, dirpath)); if (!sge_is_directory(dirpath)) return true; errno = 0; /* Maybe this should be made reentrant, though there's existing code which does the same sort of thing in the same context. */ if ((dir = opendir(dirpath)) == NULL) { ERROR((SGE_EVENT, MSG_FILE_CANTOPENDIRECTORYX_SS, dirpath, strerror(errno))); DRETURN(false); } while ((dent = readdir(dir))) if ((DT_DIR == dent->d_type) && sge_strisint(dent->d_name)) remove_shepherd_cpuset(job, task, atoi(dent->d_name)); closedir(dir); if (rmdir(dirpath) != 0) { ERROR((SGE_EVENT, MSG_FILE_RMDIRFAILED_SS, dirpath, strerror(errno))); DRETURN(false); } DRETURN(true); #endif /* !__linux__ */ }
/****** uti/signal/sge_str2signal() ******************************************** * NAME * str2signal() -- Make a SGE/SGEEE signal out of a string * * SYNOPSIS * u_long32 sge_str2signal(const char *str) * * FUNCTION * Make a sge signal out of a string. 'str' can be the signal name * (caseinsensitive) without sig or the signal number (Take care * numbers are system dependent). * * INPUTS * const char *str - signal string * * RESULT * u_long32 - SGE/EE signal * * NOTES * MT-NOTE: sge_str2signal() is MT safe * ******************************************************************************/ u_long32 sge_str2signal(const char *str) { const sig_mapT *mapptr=sig_map; u_long32 signum; /* look for signal names in mapping table */ while (mapptr->sge_sig) { if (!strcasecmp(str, mapptr->signame)) { return mapptr->sge_sig; } mapptr++; } /* could not find per name -> look for signal numbers */ if (sge_strisint(str)) { signum = strtol(str, NULL, 10); mapptr = sig_map; while (mapptr->sge_sig) { if ((int) signum == mapptr->sig) { return mapptr->sge_sig; } mapptr++; } } return -1; }