LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   shmget returns invalid segment size specified (https://www.linuxquestions.org/questions/programming-9/shmget-returns-invalid-segment-size-specified-499242/)

BobS0327 11-06-2006 07:03 PM

shmget returns invalid segment size specified
 
My OS is Fedora Core 5 and I get a EINVAL error, Invalid segement size specified on the shmget function below. The value of shared_data_size variable is 9,216,964. I used sysctl to determine the value of kernel.shmmax. This value is 33,554,433.

Anybody have any suggestions?
Code:

int getsharedmem(vodi)
{
 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;
}


exvor 11-08-2006 01:49 PM

Im thinking you ment
Code:


int getsharedmem(vodi)

/* To be */

int getsharedmem(void)



All times are GMT -5. The time now is 07:19 AM.