+
+ int *pids= calloc(construct->count, sizeof(int));
+ for (uint32_t x= 0; x < construct->count; x++)
+ {
+ char buffer[PATH_MAX]; /* Nothing special for number */
+
+ snprintf(buffer, sizeof(buffer), PID_FILE_BASE, x);
+
+ uint32_t counter= 3000; // Absurd, just to catch run away process
+ while (pids[x] <= 0 && --counter)
+ {
+ FILE *file= fopen(buffer, "r");
+ if (file)
+ {
+ char pid_buffer[1024];
+ char *found= fgets(pid_buffer, sizeof(pid_buffer), file);
+
+ if (found)
+ {
+ pids[x]= atoi(pid_buffer);
+ fclose(file);
+
+ if (pids[x] > 0)
+ break;
+ }
+ fclose(file);
+ }
+ global_sleep();
+ }
+
+ bool was_started= false;
+ if (pids[x] > 0)
+ {
+ counter= 30;
+ while (--counter)
+ {
+ if (kill(pids[x], 0) == 0)
+ {
+ was_started= true;
+ break;
+ }
+ global_sleep();
+ }
+ }
+
+ if (was_started == false)
+ {
+ fprintf(stderr, "Failed to open buffer %s(%d)\n", buffer, pids[x]);
+ for (uint32_t y= 0; y < construct->count; y++)
+ {
+ if (pids[y] > 0)
+ kill(pids[y], SIGTERM);
+ }
+ abort();
+ }
+ }
+ free(pids);
+