4 messages in net.java.dev.jna.usersRe: [jna-users] Attempt at DNotify
FromSent OnAttachments
Erik EarleJan 30, 2009 1:25 pm.log, .java
Timothy WallJan 31, 2009 5:50 pm 
Timothy WallJan 31, 2009 5:53 pm 
Daniel KaufmannFeb 2, 2009 6:00 pm 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:Re: [jna-users] Attempt at DNotifyActions...
From:Daniel Kaufmann (dani@gmail.com)
Date:Feb 2, 2009 6:00:06 pm
List:net.java.dev.jna.users

It is tricky to use signals, specially in java, since the JVM uses signals itself and also since the java code is being called in the signal hander it will make calls to the JNI code to make the thread a java thread, and I doubt that methods are async-signal-safe. Not sure if this is causing the error you are facing but anyway I recomend you check the links below for more detailed information and workarounds (in the ibm link check for sun.misc.Signal usage, it might allow you to do what you are trying to do, not sure) http://www.javakb.com/Uwe/Forum.aspx/java-jvm/166/JNI-DetachCurrentThread-leads-to-Signal-11-SIGSEGV-on-Linux http://java.sun.com/j2se/1.4.2/docs/guide/vm/signal-chaining.html http://www.ibm.com/developerworks/java/library/i-signalhandling/ Regards Daniel<http://www.opengroup.org/onlinepubs/009695399/functions/xsh_chap02_04.html>

On 1/30/09, Erik Earle <erik@yahoo.com> wrote:

I tried to duplicate the c example for dnotify.c here: http://souptonuts.sourceforge.net/code/dnotify.c.html

The attached is what I came up with. It works... somewhat. - I get segmentation faults if I do anything other than touch or rm a file, (opening a file with vi or 'echo foo > foo.txt' causes the fault) - I don't get modified events. - In spite of setting the flag for the calling the 3 arg callback, it still only calls the single arg callback.

I'm running: - Ubuntu Gutsy, Linux xxxxx 2.6.24-23-generic #1 SMP Thu Nov 27 18:44:42 UTC 2008 i686 GNU/Linux - java version "1.6.0_07" - jna-3.0.7

I've tried to get a memory dump using the instructions here: https://jna.dev.java.net/#struct_debug (the "-Djna.dump_memory=true" prop) but I the output just show this: sigaction: DNotify$SigAction(allocated@0x81155f0 (144 bytes)) { DNotify$__sighandler_t sa_sighandler@0 =com.sun.jna.examples.linux.DNotify$1@1cd8669 DNotify$__sigaction_t sa_sigaction@4 =com.sun.jna.examples.linux.DNotify$2@337838 DNotify$__sigset_t sa_mask@8=DNotify$__sigset_t(allocated@0x8158810 (128 bytes)) { int __val[32]@0=[I@119cca4 } int sa_flags@88=4 DNotify$__sigrestorer_t sa_restorer@8c =com.sun.jna.examples.linux.DNotify$3@ca2dce } memory dump [00000000] [00000000] [00000000] .... (just keeps repeating the zeros)

sometimes I get a core dump, that's also attached.

Any thoughts?