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
11 #include <sys/types.h>
13 #include <java/lang/String.h>
15 // FIXME: we don't need all these
16 #include <java/lang/String.h>
17 #include <org/xwt/Surface.h>
18 #include <org/xwt/Picture.h>
19 #include <org/xwt/js/JS.h>
20 #include <org/xwt/Box.h>
21 #include <org/xwt/util/Semaphore.h>
22 #include <org/xwt/Platform.h>
23 #include <java/lang/Long.h>
24 #include <java/util/Hashtable.h>
25 #include <org/xwt/util/Log.h>
26 #include <org/xwt/plat/POSIX.h>
27 #include <java/lang/System.h>
28 #include <java/io/PrintStream.h>
30 jstring org::xwt::plat::POSIX::_getEnv(jstring key) {
31 int len = JvGetStringUTFLength(key);
33 JvGetStringUTFRegion(key, 0, len, buf);
35 char* envstr = getenv(buf);
36 return envstr == NULL ? NULL : JvNewStringLatin1(envstr);
39 void org::xwt::plat::POSIX::spawnChildProcess(JArray<jstring>* cmd) {
40 jstring* cmdstrings = elements(cmd);
41 char* cmd2[cmd->length + 1];
42 cmd2[cmd->length] = NULL;
43 for(int i=0; i<cmd->length; i++) {
44 cmd2[i] = (char*)malloc(JvGetStringUTFLength(cmdstrings[i]));
45 JvGetStringUTFRegion(cmdstrings[i], 0, JvGetStringUTFLength(cmdstrings[i]), cmd2[i]);
49 signal(SIGHUP, SIG_IGN);
50 signal(SIGQUIT, SIG_IGN);
51 signal(SIGINT, SIG_IGN);
52 signal(SIGTERM, SIG_IGN);
54 // ignore SIGPIPE in case we were launched from a browser and the browser closed
55 signal(SIGPIPE, SIG_IGN);
57 execvp(cmd2[0], cmd2);