Skip to content

Commit

Permalink
retry shm open
Browse files Browse the repository at this point in the history
  • Loading branch information
henkwiedig committed Dec 22, 2024
1 parent b9b5373 commit 7dd36c8
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions osd/util/Render_Rockchip.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,22 @@ typedef struct {
extern int AHI_TiltY;
int Init_x86(uint16_t *width, uint16_t *height) {
// Create shared memory region

const char *shm_name = "msposd"; // Name of the shared memory region

// Open the shared memory segment
int shm_fd = shm_open(shm_name, O_RDWR, 0666);
if (shm_fd == -1) {
perror("Failed to open shared memory");
return -1;
int shm_fd = -1;

// Wait until the shared memory segment exists
while (shm_fd == -1) {
shm_fd = shm_open(shm_name, O_RDWR, 0666);
if (shm_fd == -1) {
if (errno == ENOENT) {
printf("Shared memory '%s' does not exist. Waiting...\n", shm_name);
sleep(1); // Wait for 1 second before trying again
continue;
} else {
perror("Failed to open shared memory");
return -1;
}
}
}

// Map just the header to read width and height
Expand Down

0 comments on commit 7dd36c8

Please sign in to comment.