1 // Copyright 2000-2005 the Contributors, as shown in the revision logs.
2 // Licensed under the GNU General Public License version 2 ("the License").
3 // You may not use this file except in compliance with the License.
5 // see below for copyright information on the second portion of this file
7 #include <java/lang/String.h>
8 #include <org/ibex/graphics/Surface.h>
9 #include <org/ibex/graphics/Picture.h>
10 #include <org/ibex/js/JS.h>
11 #include <org/ibex/core/Box.h>
12 #include <org/ibex/util/Semaphore.h>
13 #include <org/ibex/plat/Platform.h>
14 #include <java/lang/Long.h>
15 #include <java/util/Hashtable.h>
16 #include <org/ibex/util/Log.h>
17 #include <org/ibex/plat/POSIX.h>
18 #include <java/lang/System.h>
19 #include <java/io/PrintStream.h>
28 #include <sys/types.h>
31 jstring org::ibex::plat::POSIX::_getEnv(jstring key) {
32 int len = JvGetStringUTFLength(key);
34 JvGetStringUTFRegion(key, 0, len, buf);
36 char* envstr = getenv(buf);
37 return envstr == NULL ? NULL : JvNewStringLatin1(envstr);
40 void org::ibex::plat::POSIX::spawnChildProcess(JArray<jstring>* cmd) {
41 jstring* cmdstrings = elements(cmd);
42 char* cmd2[cmd->length + 1];
43 cmd2[cmd->length] = NULL;
44 for(int i=0; i<cmd->length; i++) {
45 cmd2[i] = (char*)malloc(JvGetStringUTFLength(cmdstrings[i]));
46 JvGetStringUTFRegion(cmdstrings[i], 0, JvGetStringUTFLength(cmdstrings[i]), cmd2[i]);
50 signal(SIGHUP, SIG_IGN);
51 signal(SIGQUIT, SIG_IGN);
52 signal(SIGINT, SIG_IGN);
53 signal(SIGTERM, SIG_IGN);
55 // ignore SIGPIPE in case we were launched from a browser and the browser closed
56 signal(SIGPIPE, SIG_IGN);
58 execvp(cmd2[0], cmd2);