5 messages in net.java.dev.jna.users[jna-users] Help required with fork...
FromSent OnAttachments
rzoAug 16, 2008 7:40 am 
Daniel KaufmannAug 16, 2008 10:42 am 
rzoAug 19, 2008 10:02 am 
Timothy WallAug 19, 2008 10:43 am.java
Daniel KaufmannAug 19, 2008 5:55 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:[jna-users] Help required with fork/execActions...
From:rzo (rz@gmx.de)
Date:Aug 16, 2008 7:40:19 am
List:net.java.dev.jna.users

Hello,

I am trying to spawn a process using the following code. A new process is forked but hangs in execvp. A look at the process table shows that a java process is spawned but no konsole process. Is this an JNA issue ?

- Ron

public interface CLibrary extends Library {

CLibrary INSTANCE = (CLibrary)

Native.loadLibrary((System.getProperty("os.name").startsWith("Windows") ? "msvcrt" : "c"), CLibrary.class);

int atol(String s); int fork(); void exit(int status); /* * int execv (const char *filename, char *const argv[]) */ int execvp (String filename, String[] argv); } public static void main(String[] args) { System.out.println(System.getProperty("os.name")); int pid = 0; if ((pid = CLibrary.INSTANCE.fork()) == 0) { CLibrary.INSTANCE.execvp("konsole", new String[]{"konsole", "--noclose"}); CLibrary.INSTANCE.exit(-1); } else if (pid > 0) { System.out.println("forked "+pid); try { Thread.sleep(10000); } catch (InterruptedException e) { e.printStackTrace(); } } else if (pid < 0) System.out.println("could not fork a process"); }