1 // Copyright 2002 Adam Megacz, see the COPYING file for licensing [LGPL]
2 // see below for copyright information on the second portion of this file
4 #include <java/lang/String.h>
5 #include <org/ibex/graphics/Surface.h>
6 #include <org/ibex/graphics/Picture.h>
7 #include <org/ibex/js/JS.h>
8 #include <org/ibex/core/Box.h>
9 #include <org/ibex/util/Semaphore.h>
10 #include <org/ibex/plat/Platform.h>
11 #include <java/lang/Long.h>
12 #include <java/util/Hashtable.h>
13 #include <org/ibex/util/Log.h>
14 #include <org/ibex/plat/POSIX.h>
15 #include <java/lang/System.h>
16 #include <java/io/PrintStream.h>
25 #include <sys/types.h>
28 jstring org::ibex::plat::POSIX::_getEnv(jstring key) {
29 int len = JvGetStringUTFLength(key);
31 JvGetStringUTFRegion(key, 0, len, buf);
33 char* envstr = getenv(buf);
34 return envstr == NULL ? NULL : JvNewStringLatin1(envstr);
37 void org::ibex::plat::POSIX::spawnChildProcess(JArray<jstring>* cmd) {
38 jstring* cmdstrings = elements(cmd);
39 char* cmd2[cmd->length + 1];
40 cmd2[cmd->length] = NULL;
41 for(int i=0; i<cmd->length; i++) {
42 cmd2[i] = (char*)malloc(JvGetStringUTFLength(cmdstrings[i]));
43 JvGetStringUTFRegion(cmdstrings[i], 0, JvGetStringUTFLength(cmdstrings[i]), cmd2[i]);
47 signal(SIGHUP, SIG_IGN);
48 signal(SIGQUIT, SIG_IGN);
49 signal(SIGINT, SIG_IGN);
50 signal(SIGTERM, SIG_IGN);
52 // ignore SIGPIPE in case we were launched from a browser and the browser closed
53 signal(SIGPIPE, SIG_IGN);
55 execvp(cmd2[0], cmd2);