Cross-process locking with Android NDK? -
is there way lock e.g. using mutexes or file locks on android ndk, across processes?
i want lock socket 1 process can send @ once. processes not forked, independent invocations.
as writing shared library, cannot rely on shared location requires permissions write it, neither can use process local storage, because unable share other processes definition. goes app names too. i'm looking abstract namespaces af_unix sockets, mutex/semaphores.
assuming processes have same user id, can use flock(2)
lock file (could accessible both processes), or posix semaphore operations (sem_open(3)
) use semaphore.
if user ids different, mechanisms still work, have set file permissions more "open" -- introduces risk of malicious app performing denial-of-service attack grabbing lock.
Comments
Post a Comment