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=ChS5V/1Spsrjo/m2oszmoE7Jcn7T9GX8oNHYfo8NVCU=; b=qKSpBbBKM7zgxm6+NLcz0OBqKVsWECRzFhjhwskzNP/KCNTWoD4Spyn2OucwfiNZyJ 9Fn1fHz7UNtfzuyDZXFFQrKUIyIPAO19Z8KlIFGg7OhwKji9SmYyBDgd+Af/dFz52GVn CY7WwxiWrBGLC22ct/D9ZhMrM+NFb59Mphsjs= 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=xmaEekCXoR9XEblGYxjlZfDxs7aS6tfzewnNQGaU2dIR64U9C7l9DsHu6BYziPak+p NXAlY5JyLB8EKzNC251KlcDWTP7SQTqXEcGTGt7oo9fGS8rTBd4Gnw2K9NCUNhkt0OK/ 0UVxABz9WA6WHmCG5KbUQP+YdHkOcfDeJohvM= 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