+void create_file(const char *path)
+{
+ static bool file_created = false;
+ int ret;
+
+ if (!path || file_created) {
+ return;
+ }
+
+ ret = creat(path, S_IRWXU);
+ if (ret < 0) {
+ fprintf(stderr, "Failed to create file %s\n", path);
+ return;
+ }
+
+ (void) close(ret);
+ file_created = true;
+}
+
+static
+void wait_on_file(const char *path)
+{
+ if (!path) {
+ return;
+ }
+ for (;;) {
+ int ret;
+ struct stat buf;
+
+ ret = stat(path, &buf);
+ if (ret == -1 && errno == ENOENT) {
+ (void) poll(NULL, 0, 10); /* 10 ms delay */
+ continue; /* retry */
+ }
+ if (ret) {
+ perror("stat");
+ exit(EXIT_FAILURE);
+ }
+ break; /* found */
+ }
+}
+