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/Box.h>
20 #include <org/xwt/util/Semaphore.h>
21 #include <org/xwt/Platform.h>
22 #include <java/lang/Long.h>
23 #include <java/util/Hashtable.h>
24 #include <org/xwt/util/Log.h>
25 #include <org/xwt/plat/POSIX.h>
26 #include <java/lang/System.h>
27 #include <java/io/PrintStream.h>
29 jstring org::xwt::plat::POSIX::_getEnv(jstring key) {
30 int len = JvGetStringUTFLength(key);
32 JvGetStringUTFRegion(key, 0, len, buf);
34 char* envstr = getenv(buf);
35 return envstr == NULL ? NULL : JvNewStringLatin1(envstr);
38 void org::xwt::plat::POSIX::spawnChildProcess(JArray<jstring>* cmd) {
39 jstring* cmdstrings = elements(cmd);
40 char* cmd2[cmd->length + 1];
41 cmd2[cmd->length] = NULL;
42 for(int i=0; i<cmd->length; i++) {
43 cmd2[i] = (char*)malloc(JvGetStringUTFLength(cmdstrings[i]));
44 JvGetStringUTFRegion(cmdstrings[i], 0, JvGetStringUTFLength(cmdstrings[i]), cmd2[i]);
48 signal(SIGHUP, SIG_IGN);
49 signal(SIGQUIT, SIG_IGN);
50 signal(SIGINT, SIG_IGN);
51 signal(SIGTERM, SIG_IGN);
53 // ignore SIGPIPE in case we were launched from a browser and the browser closed
54 signal(SIGPIPE, SIG_IGN);
56 execvp(cmd2[0], cmd2);