version 1.2, 2019/03/24 09:51:41 |
version 1.5, 2020/10/06 06:31:20 |
|
|
* OF THE SOFTWARE HAS BEEN DEVELOPED BY A THIRD PARTY, THE THIRD PARTY |
* OF THE SOFTWARE HAS BEEN DEVELOPED BY A THIRD PARTY, THE THIRD PARTY |
* DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE, |
* DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE, |
* PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE. |
* PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE. |
* $OpenXM: OpenXM_contrib2/asir2018/io/ox_launch.c,v 1.1 2018/09/19 05:45:08 noro Exp $ |
* $OpenXM: OpenXM_contrib2/asir2018/io/ox_launch.c,v 1.4 2019/12/14 12:34:02 fujimoto Exp $ |
*/ |
*/ |
#include <setjmp.h> |
#include <setjmp.h> |
#include <signal.h> |
#include <signal.h> |
|
|
static FILE *logfile; |
static FILE *logfile; |
|
|
if ( !logfile ) |
if ( !logfile ) |
|
#if defined(ANDROID) |
|
logfile = fopen("/data/data/com.termux/files/usr/tmp/ox_log","w"); |
|
#else |
logfile = fopen("/tmp/ox_log","w"); |
logfile = fopen("/tmp/ox_log","w"); |
|
#endif |
fprintf(logfile,"%s\n",str); |
fprintf(logfile,"%s\n",str); |
fflush(logfile); |
fflush(logfile); |
} |
} |
|
|
|
|
/* XXX a dirty hack */ |
/* XXX a dirty hack */ |
if ( !getenv("LD_LIBRARY_PATH") ) { |
if ( !getenv("LD_LIBRARY_PATH") ) { |
if ( e = getenv("OpenXM_HOME") ) { |
if ( ( e = getenv("OpenXM_HOME") ) != 0 ) { |
s = (char *)alloca(strlen(e)+100); |
s = (char *)alloca(strlen(e)+100); |
sprintf(s,"LD_LIBRARY_PATH=%s/lib",e); |
sprintf(s,"LD_LIBRARY_PATH=%s/lib",e); |
putenv(s); |
putenv(s); |
|
|
if ( bs != 4 && dup2(bs,4) != 4 ) |
if ( bs != 4 && dup2(bs,4) != 4 ) |
exit(1); |
exit(1); |
{ |
{ |
#if defined(linux) || defined(__NeXT__) || defined(ultrix) || defined(__CYGWIN__) |
#if defined(ANDROID) |
|
#include <sys/resource.h> |
|
struct rlimit rl; |
|
|
|
getrlimit(RLIMIT_NOFILE,&rl); |
|
close(0); |
|
for ( i = 5; i < rl.rlim_cur; i++ ) |
|
close(i); |
|
#elif defined(linux) || defined(__NeXT__) || defined(ultrix) || defined(__CYGWIN__) |
#include <sys/param.h> |
#include <sys/param.h> |
close(0); |
close(0); |
for ( i = 5; i < NOFILE; i++ ) |
for ( i = 5; i < NOFILE; i++ ) |
|
|
exit(0); |
exit(0); |
} |
} |
|
|
|
#define asir_OperandStackSize BUFSIZ |
|
|
static void ox_io_init(sock) |
static void ox_io_init(sock) |
int sock; |
int sock; |
{ |
{ |
endian_init(); |
endian_init(); |
/* server mode */ |
/* server mode */ |
sindex = get_iofp(sock,0,1); |
sindex = get_iofp(sock,0,1); |
asir_OperandStack = (Obj *)CALLOC(BUFSIZ,sizeof(Obj)); |
asir_OperandStack = (Obj *)CALLOC(asir_OperandStackSize,sizeof(Obj)); |
asir_OperandStackPtr = -1; |
asir_OperandStackPtr = -1; |
} |
} |
|
|
static void push_one(obj) |
static void push_one(obj) |
Obj obj; |
Obj obj; |
{ |
{ |
|
if ( asir_OperandStackPtr == asir_OperandStackSize-1 ) |
|
return; |
if ( !obj || OID(obj) != O_VOID ) |
if ( !obj || OID(obj) != O_VOID ) |
asir_OperandStack[++asir_OperandStackPtr] = obj; |
asir_OperandStack[++asir_OperandStackPtr] = obj; |
} |
} |
|
|
static Obj pop_one() { |
static Obj pop_one() { |
if ( asir_OperandStackPtr >= 0 ) { |
if ( asir_OperandStackPtr >= 0 ) { |
return asir_OperandStack[asir_OperandStackPtr--]; |
return asir_OperandStack[asir_OperandStackPtr--]; |
} |
} else |
|
return 0; |
} |
} |
|
|
static void terminate_server(int sig) |
static void terminate_server(int sig) |