=================================================================== RCS file: /home/cvs/OpenXM_contrib2/asir2000/io/ox_launch.c,v retrieving revision 1.14 retrieving revision 1.18 diff -u -p -r1.14 -r1.18 --- OpenXM_contrib2/asir2000/io/ox_launch.c 2001/07/23 05:05:41 1.14 +++ OpenXM_contrib2/asir2000/io/ox_launch.c 2004/03/02 10:34:49 1.18 @@ -44,7 +44,7 @@ * OF THE SOFTWARE HAS BEEN DEVELOPED BY A THIRD PARTY, THE THIRD PARTY * DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE, * PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE. - * $OpenXM: OpenXM_contrib2/asir2000/io/ox_launch.c,v 1.13 2001/06/27 09:14:08 noro Exp $ + * $OpenXM: OpenXM_contrib2/asir2000/io/ox_launch.c,v 1.17 2004/03/02 02:43:55 noro Exp $ */ #include #include @@ -78,7 +78,7 @@ static int which_command(char *,char *); static int search_command(char *); static int ox_spawn(char *,int,char *,int); static void launch_error(char *); -static int ox_io_init(int); +static void ox_io_init(int); static void push_one(Obj); static Obj pop_one(); static void do_cmd(int); @@ -156,15 +156,19 @@ void launch_main(argc,argv) int argc; char **argv; { - int id; - Obj p,obj; +#if !defined(VISUAL) + Obj p; char *name; char buf[BUFSIZ]; +#endif + int id; + Obj obj; int cs,ss; unsigned int cmd; int use_unix,accept_client,nolog; char *control_port_str,*server_port_str; char *rhost,*server,*dname; + char *e,*s; GC_init(); nglob_init(); gethostname(hostname,BUFSIZ); @@ -182,6 +186,7 @@ char **argv; #endif signal(SIGINT,SIG_IGN); + signal(SIGHUP,SIG_IGN); #if defined(SIGUSR1) signal(SIGUSR1,SIG_IGN); #endif @@ -189,6 +194,15 @@ char **argv; signal(SIGTERM,terminate_server); #endif + /* XXX a dirty hack */ + if ( !getenv("LD_LIBRARY_PATH") ) { + if ( e = getenv("OpenXM_HOME") ) { + s = (char *)alloca(strlen(e)+100); + sprintf(s,"LD_LIBRARY_PATH=%s/lib",e); + putenv(s); + } + } + if ( accept_client ) { cs = try_bind_listen(use_unix,control_port_str); ss = try_bind_listen(use_unix,server_port_str); @@ -226,10 +240,6 @@ static void do_cmd(cmd) int cmd; { USINT t; - int id,cindex; - int bport,sport; - int bs,bs0; - STRING prog,dname; switch ( cmd ) { case SM_shutdown: @@ -293,7 +303,7 @@ int nolog; char *av[BUFSIZ]; char sock_id[BUFSIZ],ox_intr[BUFSIZ],ox_reset[BUFSIZ],ox_kill[BUFSIZ]; char AsirExe[BUFSIZ]; - HANDLE hProc; + int hProc; STRING rootdir; int mypid; int newbs; @@ -333,16 +343,16 @@ int nolog; char errcode; pid = fork(); - if ( pid ) + if ( pid ) { return pid; - else { + } else { setpgid(0,getpid()); - if ( dup2(bs,3) != 3 ) + if ( bs != 3 && dup2(bs,3) != 3 ) exit(1); - if ( dup2(bs,4) != 4 ) + if ( bs != 4 && dup2(bs,4) != 4 ) exit(1); { -#if defined(linux) || defined(__NeXT__) || defined(ultrix) +#if defined(linux) || defined(__NeXT__) || defined(ultrix) || defined(__CYGWIN__) #include close(0); for ( i = 5; i < NOFILE; i++ ) @@ -391,7 +401,7 @@ char *s; exit(0); } -static int ox_io_init(sock) +static void ox_io_init(sock) int sock; { endian_init(); @@ -414,7 +424,7 @@ static Obj pop_one() { } } -static void terminate_server() +static void terminate_server(int sig) { #if defined(SIGKILL) kill(cpid,SIGKILL);