LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-06-2006, 07:03 PM   #1
BobS0327
LQ Newbie
 
Registered: Apr 2006
Posts: 4

Rep: Reputation: 0
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;
}
 
Old 11-08-2006, 01:49 PM   #2
exvor
Senior Member
 
Registered: Jul 2004
Location: Phoenix, Arizona
Distribution: Gentoo, LFS, Debian,Ubuntu
Posts: 1,537

Rep: Reputation: 87
Im thinking you ment
Code:
 
int getsharedmem(vodi) 

/* To be */ 

int getsharedmem(void)
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
shmget() returns the different ID for the same key lordofring Programming 3 08-28-2006 11:42 AM
*** glibc detected *** free(): invalid next size (normal): 0x0804c050 *** water&sky Linux - General 2 03-03-2006 12:25 PM
Bash script that returns the size of a file spank Linux - General 6 01-19-2006 03:24 PM
Why Linux returns the device size for 1 block more when it could be read?? fa3a Programming 1 01-29-2004 06:23 AM
cdrecord -scanbus sez: "controller returns wrong size for capapabilities page rdaves@earthlink.net Linux - General 5 10-08-2001 09:09 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:44 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration