2

So on Android there's neither POSIX shared memory nor SysV shared memory, but there's ashmem. I want to use it to collect some postmortem info from crashes in the native subsystem (like in here). Question - can I make an ashmem region persist when the process that holds the handle to them dies? Where's ashmem documented?

Community
  • 1
  • 1
Seva Alekseyev
  • 59,826
  • 25
  • 160
  • 281

1 Answers1

1

Looks like there's no builtin way to make a region stick. So I've built an out-of-process service, I pass a descriptor to a region to it, and hope the service outlives the main process. There's no lifetime guarantee for background services on Android, as everyone knows.

The service has a static variable of type ParcelFileDescriptor and supports two binder commands - GET and SET. They, respectively, return the said descriptor in the response parcel and assign it from the request parcel, closing the currently held one (if any).

Seva Alekseyev
  • 59,826
  • 25
  • 160
  • 281