My OS is Fedora Core 5. The shmget funtion generates a EINVAL error which indicates that a invalid segment size was specified. A review of the shmget docs indicates that a possible cause of this problem is that SHMMAX is set below the size of the data size. I checked the kernel.shmmax value using sysctl. It was set at 33,554,433. My shared_data_size variable contained 9,216,964, which is well below SHMMAX.

Anybody have any suggestions?

Code:
int getsharedmem(void)
{
int cam = 0;
 long long shm_key=0x7a6d2000;
     size_t shared_data_size = sizeof(SharedData) +
                                  sizeof(TriggerData) +
                                  ((*monitor[cam]->image_buffer_count)*(sizeof(struct timeval))) +
                                  ((*monitor[cam]->image_buffer_count)*(*monitor[cam]->width)*(*monitor[cam]->height)*3);
        int shmid;
        if((shmid=shmget((shm_key&0xffffff00)|monitor[cam]->mon_id,shared_data_size,SHM_R))==-1)
        {
            printf("Failed to shmget error = %s\n",strerror(errno));
            if(errno == EINVAL)
                printf("Invalid segment size specified\n");
            else if(errno == EEXIST)
                printf("Segment exists, cannot create it\n");
            else if(errno == EIDRM)
                printf("Segment is marked for deletion or was removed\n");
            else if(errno == ENOENT)
                printf("Segment does not exist\n");
            else if(errno == EACCES)
                printf("Permission denied\n");
            else if(errno == ENOMEM)
                printf("Not enough memory to create segment\n");

            printf("monitor[%d]->mon_id = %d shared_data_size = %d\n",cam, monitor[cam]->mon_id,shared_data_size);
            // The above errno returns "Invalid argument"
            fprintf(stderr,"ERROR: Failed to shmget\n");
            return EXIT_FAILURE;
         }
return 0;
}