

![]() | Start a set with this search |
![]() | Include this search in one of my sets |
![]() | Exclude this search from one of my sets |
![]() | Permalink to these results Paste this link in email or IM: |
| Atom feed for tracking future search results Paste this URL into your reader: |
8 messages in net.java.dev.jna.usersRe: [jna-users] Is there a way to han...| From | Sent On | Attachments |
|---|---|---|
| Dennis Portello | May 14, 2007 7:27 am | |
| Wayne Meissner | May 14, 2007 5:59 pm | |
| Dennis Portello | May 15, 2007 10:48 pm | |
| Wayne Meissner | May 16, 2007 3:54 am | |
| Timothy Wall | May 16, 2007 5:51 am | |
| Timothy Wall | Aug 27, 2007 9:53 am | |
| Dennis Portello | Aug 27, 2007 9:59 am | |
| Timothy Wall | Aug 27, 2007 11:27 am |

![]() | Permalink for this message Paste this link in email or IM: |
![]() | Permalink for this thread Paste this link in email or IM: |
| Atom feed for this thread Paste this URL into your reader: |
| Subject: | Re: [jna-users] Is there a way to handle a union construct? | Actions... |
|---|---|---|
| From: | Dennis Portello (denn...@gmail.com) | |
| Date: | May 15, 2007 10:48:56 pm | |
| List: | net.java.dev.jna.users | |
Thank you!
I meant sigaction, not sigalert. I've also discovered that it was unnecessary to create a signal handler for my application.
I'm intrigued by the example you provided (and this entire project). I've been looking at the Structure class to see if I could derive a Union class from it. My C is a bit rusty these days, so I'm looking for a nice challenge.
-Dennis P
On 5/14/07, Wayne Meissner <wmei...@gmail.com> wrote:
Dennis Portello wrote:
Hi,
I've been experimenting with JNA over the last few days to gain access to POSIX functions on Linux/Unix.
So far I've had success with calling setuid when running Apache Tomcat so I can start as root and move to a non-privileged account during runtime.
For my next trick, I'd like to write a signal handler so I can initiate a proper shutdown when a SIGINT or SIGHUP is caught.
My dilemma is this, I was in the process of implementing the sigalert struct in java when I came across a union. I've looked around the jna code, examples on the site, and whatever emails I could find and found nothing regarding this issue.
I couldn't find the sigalert structure anywhere. Did you mean struct sigaction, with its union of function pointers?
Assuming sigaction, there currently isn't any way to set function pointers in a structure anyway - so using the old signal(3) call might be a better bet to hook signal handlers for now.
Could someone provide insight as to how I might handle a c union with JNA, or is this something that's not currently possible?
There is no easy way to do it currently. You can always point multiple structures at the same memory region. e.g. class Foo extends Structure { public int i1; public int i2;
public Foo(Pointer p) { useMemory(p); } } class Bar extends Structure { public long l; public Bar(Pointer p) { useMemory(p); } } Pointer p = new Memory(...) Foo f = new Foo(p); foo.i1 = 0xdeadbeef; foo.i2 = 0xcafebabe; foo.write(); Bar b = new Bar(p); b.read(); System.out.println("l=" + b.l);







