• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: POSIX shared memory question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: POSIX shared memory question


  • Subject: Re: POSIX shared memory question
  • From: Brian Bergstrand <email@hidden>
  • Date: Wed, 31 May 2006 17:04:21 -0500

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


On May 31, 2006, at 3:38 PM, Philip Lukidis wrote:

Hello. I have a question for using POSIX shared memory. There is a possibility that my process could crash before it would have called shm_unlink. I have two basic questions:

a) What is the best method to deal with cleanup? I guess catching as many relevant signals as possible and cleaning up might help (SIGSEGV, SIGBUS, SIGABRT come to mind, though I'm not sure I could catch them), but is there a better approach, or complementary operations? There are at least two signals which I cannot catch. According to the manpage of shm_open, shared memory references do not survive a reboot, but I'd like to keep the filesystem as clean as possible.

You could also create a destructor function and cleanup there, but either way it's still possible leave a dangling reference. You can't guarantee anything if you end up crashing.


b) After I create the shared memory object via shm_open, call ftruncate, and map it via mmap, should I not see the object in the filesystem (well, after shm_open at least)? So far I cannot find it through the shell, yet no error is returned in my code. Is it created in a different namespace?

Not unless you actually provide a valid path. Otherwise, an anonymous memory object is created in the kernel only with no representation in the FS.


How can I view all created shared memory objects in the system?

ipcs

Unfortunately, that only works for SYSV objects. The POSIX ipcs equivalent is not included with OS X, so you are SOL there.


thanks for any help,

Philip Lukidis

-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.3 (Darwin)

iD8DBQFEfhLredHYW7bHtqIRAgF1AJsHAry8WGkZO2d8GpcFK9+xM0vS3ACgiS6n
JiZHszJK6j9dPWIf1mnivmk=
=eygN
-----END PGP SIGNATURE-----
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >POSIX shared memory question (From: "Philip Lukidis" <email@hidden>)

  • Prev by Date: POSIX shared memory question
  • Next by Date: Re: DADiskEject and Resource Busy errors
  • Previous by thread: POSIX shared memory question
  • Next by thread: Behavior or "less" on different systems?
  • Index(es):
    • Date
    • Thread