site_archiver@lists.apple.com Delivered-To: darwin-dev@lists.apple.com Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=M3NtF5lhObIZmYDhQCpDc78ddV6ch1lfY63PXlRN0V0=; b=YuG+keroAQWUZ3C17sf0hfmwLMBNoBZHU3kfuk7sy2BguC/jPOtHM2TmwSPp2mBDAI 8O46FKecVOlH2nH6kPRJzM5Vy4Xhf+1nxRkGv32h0xl7Dg1gxxuOqmeXYpoyVsiS9RNL Isjklt+KlQYdQY03UOw+BWjP5DBkX0QR1hWL8= Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=rHRCQOWFLHDmP0jihSE1wqFcAuuYyqt9TBqVMJ4kKWXGAJTG1uJdG64t72NRXGFNad lAVDgvqLJ0pDJ0Hvac7VmpGgOZ9hvcerQ1ryh8B6mJP+Q/fsFrSzKPFEqdNNKgJlmINm xYkF7rmchiGMSfDkU9LmLjFkWm/vsN/cQq7mU= shmget() should be returning EINVAL only if no memory segment is to be created (IPC_CREAT not specified) and EEXIST if memory segment is to be created. However, Mac OS X is returning EINVAL even when I am using shmget() to create a memory segment. The same program on Linux/Hp-UX works fine (returns EINVAL when I call shmget() without IPC_EXCL and EEXIST when I call it with IPC_EXCL) Also the Mac OS X man page is saying that EINVAL would be returned when no shared memory segment is to be created and a segment exists with a size lesser then size requested. Has anyone faced this problem. Any solutions / comments on this ? Thanks, Rohan On Sat, Dec 5, 2009 at 8:00 PM, rohan a <info1686@gmail.com> wrote:
Hi,
I do not think the key is invalid because shmget() with the same key has succeeded several times. Is it possible to use another key if either EEXIST or EINVAL is returned or should I necessarily have to check using shmctl() if another process is using that key ?
Thanks, Rohan
On Sat, Dec 5, 2009 at 11:53 AM, Tyler Sample <tyler.sample@gmail.com> wrote:
EINVAL is also returned if your key is entirely invalid. Double check that before your function call.
If that's not the problem, if the shmget call fails, you can try making another call with the size set to 0, then make sure that call succeeds. Then you can use shmctl to find out about the memory....In particular, you can print the size. If it's something reasonable, you probably have a duplicate key with another process.
----- Original Message ----- From: "rohan a" <info1686@gmail.com> To: <darwin-dev@lists.apple.com> Sent: Friday, December 04, 2009 9:30 PM Subject: shmget() returning EINVAL for constant size and flags
Hello All, I am using shmget() to allocate shared memory in my backup/restore utility.
int shmget(key_t key, size_t size, int shmflg);
The size and shmflg I am passing are always constant. If shmget() returns EEXIST I try again with another key until shared memory is allocated.
On some occasions, shmget() fails and I am getting an EINVAL error. I dont think the arguments are invalid because, I am using constant values for size and shmflg for every call and most of the calls are successful.
The Man page says this for EINVAL :
[EINVAL] No shared memory segment is to be created, and a shared memory segment exists for key, but the size of the segment associated with it is less than size, which is non-zero. nonzero. zero.
However, with every shmget() call, I use the same size 524288 and same flags with different key ofcourse.
Then why should I get an EINVAL ?
Is it possible that another application is allocating shared memory using this key but a size lesser than 524288 ?
Along with checking EEXIST for existence of a memory location with this key should I also check for EINVAL ? That is if EINVAL is returned, should I try to allocate with another key ?
Thanks, Rohan _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/tyler.sample%40gmail.com
This email sent to tyler.sample@gmail.com
_______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.appl... This email sent to site_archiver@lists.apple.com