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?