6 messages in net.java.dev.jna.usersRe: [jna-users] Re: JNA (fork and exec)
FromSent OnAttachments
Timothy WallAug 27, 2007 12:59 pm 
Wayne MeissnerAug 27, 2007 5:28 pm 
Jagadeeswaran RajendiranAug 28, 2007 4:56 pm 
Timothy WallAug 28, 2007 6:51 pm 
Jagadeeswaran RajendiranAug 29, 2007 5:49 pm 
Timothy WallAug 29, 2007 8:48 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] Re: JNA (fork and exec)Actions...
From:Timothy Wall (twal@dev.java.net)
Date:Aug 28, 2007 6:51:58 pm
List:net.java.dev.jna.users

On Aug 28, 2007, at 7:56 PM, Jagadeeswaran Rajendiran wrote:

Thanks for the prompt replies, guys.

So, here are some more results/questions:

1. I tried using execl as follows.

libcInstance.execl("/bin/cp", "cp", "source", "destination");

But, it comes back with an errno of BAD_ADDRESS

If I change it to execv, it works (with the original problem of occassionally not working)

I need to use execv anyway, coz my program is going to spawn other programs with unknown number of arguments...and execv is the most convenient and functional coz it takes an array!

There's no problem with using execv; the String[] is automatically converted into an array of char* with a NULL final element.

2. In the code excerpt, execv never returns, which probably then means that it was never executed

execv never returns if it is successful. The java process is completely replaced by the exec'd program. If it does return, you need to check errno to see why it failed.

3. On a related note, as suggested, I tried running my application using strace:

"strace java -jar Pipeline.jar"

And it NEVER shows JNA entering fork or execv system calls, although I (after tracing JNA source code) can see that JNA goes through Function::invoke etc, calls native code...but I am not sure why I am not able to see the fork/execv call traces through strace...any ideas?

Do you see *any* strace activity from the java process? I haven't done this for a while.

Do a "kill -3" on the child process where execv fails. What does the thread dump show?