29 #include <sys/types.h>
52 char key[16] = { 0 }, procpath[128] = { 0 };
59 local_pid = atoi(entry->d_name);
60 if ((local_pid <= 0) || (strlen(entry->d_name) > 114)) {
68 strcpy(procpath,
"/proc/");
69 strcat(procpath, entry->d_name);
70 fd = open(procpath, O_RDONLY);
74 if (fstat(fd, &statbuf) < 0) {
81 if (!S_ISDIR(statbuf.st_mode)) {
90 strcat(procpath,
"/status");
91 file = fopen(procpath,
"r");
95 if ((fscanf(file,
"%15s%63s", key, name) != 2)
121 struct dirent *entry;
123 char entry_name[64] = { 0 };
125 dp = opendir(
"/proc");
127 crm_notice(
"Can not read /proc directory to track existing components");
131 while ((entry = readdir(dp)) != NULL) {
136 crm_info(
"Found %s active as process %d", name, pid);
158 stream = fopen(
"/proc/stat",
"r");
159 if (stream == NULL) {
160 crm_perror(LOG_INFO,
"Could not open /proc/stat");
164 while (fgets(buffer,
sizeof(buffer), stream)) {
171 return cores? cores : 1;
#define crm_notice(fmt, args...)
int crm_pid_active(long pid, const char *daemon)
gboolean safe_str_neq(const char *a, const char *b)
bool crm_starts_with(const char *str, const char *prefix)
Check whether a string starts with a certain sequence.
int crm_procfs_process_info(struct dirent *entry, char *name, int *pid)
unsigned int crm_procfs_num_cores(void)
#define crm_perror(level, fmt, args...)
Log a system error message.
#define safe_str_eq(a, b)
int crm_procfs_pid_of(const char *name)
#define crm_info(fmt, args...)