Hi, I tried using the jni.Global class to do interprocess locking between 2 processes. I wasn't sure whether to use Global or the Lock class. Both seem to have identical APIs.
It worked alright on Windows 7. The 2 communicating processes weren't even parent-child and it still worked. However, on Linux (Ubuntu 64bit Intel) the child process crashes at Global.childInit(..) method. Even when the second process was started by hand (not as a child process of the first using ProcessBuilder) it crashed. The first few lines of the dump shown below. The code and a related question I asked a few days ago on the same forum: [Native:JNI] Stability, usage and maintenance of shared memory and mutex code<http://markmail.org/thread/rudbjh7n3knkm4ji> Questions: 1. What is the difference between Global and Lock? 2. How do you use either one of them for inter-process locking - esp. on Linux? JVM dump: --------------- T H R E A D --------------- Current thread (0x08492000): JavaThread "main" [_thread_in_native, id=9706, stack(0xb6d10000,0xb6d61000)] siginfo:si_signo=SIGSEGV: si_errno=0, si_code=1 (SEGV_MAPERR), si_addr=0x00000000 Registers: EAX=0x8ee065fc, EBX=0xb4428ff4, ECX=0x00000000, EDX=0x00000000 ESP=0xb6d5fedc, EBP=0xb6d5fef8, ESI=0x0855b4a8, EDI=0x08492118 EIP=0x00000000, CR2=0x00000000, EFLAGS=0x00010282 Top of Stack: (sp=0xb6d5fedc) 0xb6d5fedc: b4415a76 8ee065fc 08559450 0855b4a8 0xb6d5feec: b4415a4f 0855b4a8 08551f60 b6d5ff28 0xb6d5fefc: b4415d90 8ee065fc 0855b4a8 08559450 0xb6d5ff0c: 08492118 b6d5ff78 b780b230 08559450 0xb6d5ff1c: b4415d60 b6d5ff5c b45f3ff4 b6d5ff78 0xb6d5ff2c: b45ee1fe b6d5ff5c 0855b4a8 08559450 0xb6d5ff3c: b6d5ffc4 b6fa4b8d 08492000 084928b0 0xb6d5ff4c: 08559450 084928b4 084928b4 fffffffe Instructions: (pc=0x00000000) 0xfffffff0: Stack: [0xb6d10000,0xb6d61000], sp=0xb6d5fedc, free space=13fb6d5f860k Java frames: (J=compiled Java code, j=interpreted, Vv=VM code) j org.apache.tomcat.jni.Global.childInit(Ljava/lang/String;J)J+0 j shm.ShmReader.test()V+48 j shm.ShmReader.main([Ljava/lang/String;)V+7 v ~StubRoutines::call_stub Thanks, Ashwin.