2020-05-01 12:49:58 (UTC-03:00)
Marcel Rodrigues <marcelgmr@gmail.com>
only consider dir a service if we can stat dir/run
diff --git a/isv.c b/isv.c index 73741b7..25ac990 100644 --- a/isv.c +++ b/isv.c @@ -187,6 +187,7 @@ main(int argc, char *argv[]) DIR *dir; const char *base_dir = NULL; struct dirent *entry; + struct stat st; int nservices, selection; int name_size; struct winsize term_size; @@ -212,6 +213,11 @@ main(int argc, char *argv[]) while ((entry = readdir(dir)) != NULL) { if (!strcmp(entry->d_name, ".") || !strcmp(entry->d_name, "..")) continue; + chdir(base_dir); + if (chdir(entry->d_name) == -1) + continue; + if (stat("run", &st) == -1) + continue; strncpy(services[nservices].name, entry->d_name, MAX_NAME-1); name_size = strlen(entry->d_name); if (name_size > name_col_width && name_col_width < MAX_NAME)