diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/ChangeLog | 15 | ||||
-rw-r--r-- | src/driver/Makefile.in | 2 | ||||
-rw-r--r-- | src/driver/main.c | 1 | ||||
-rw-r--r-- | src/driver/utils.c | 10 | ||||
-rw-r--r-- | src/driver/utils.h | 2 | ||||
-rw-r--r-- | src/interp/int-top.boot | 16 | ||||
-rw-r--r-- | src/sman/sman.c | 64 |
7 files changed, 68 insertions, 42 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 4d4e1d51..b2222e46 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,4 +1,17 @@ -2009-09-29 Gabriel Dos Reis <gdr@cse.tamu.edu> +2009-09-29 Gabriel Dos Reis <gdr@cs.tamu.edu> + + * sman/sman.c (fix_env): Simplify. + (exec_command_env): Lose second parameter. + (fork_Axiom): Take a new parameter. + (start_the_Axiom): Adjust. + (main): Likewise. + * interp/int-top.boot (printFirstPrompt?): New. + (SpadInterpretStream): Use it. + * driver/utils.h (openaxiom_allocate_command_argv): Declare. + * driver/utils.c (openaxiom_allocate_command_argv): Define. + * driver/Makefile.in (open-axiom$(EXEEXT)): Link statically. + +2009-09-29 Gabriel Dos Reis <gdr@cs.tamu.edu> * driver/Makefile.in (open-axiom): Link against core runtime. * driver/main.c (publish_systemdir): Rework. diff --git a/src/driver/Makefile.in b/src/driver/Makefile.in index 0141482e..4859c829 100644 --- a/src/driver/Makefile.in +++ b/src/driver/Makefile.in @@ -61,7 +61,7 @@ utils.lo: utils.h main.lo: utils.h open-axiom$(EXEEXT): $(open_axiom_objects) - $(LINK) -o $@ $(open_axiom_objects) $(open_axiom_LDADD) + $(LINK) -all-static -o $@ $(open_axiom_objects) $(open_axiom_LDADD) mostlyclean-local: @rm -f $(axiom_objects) diff --git a/src/driver/main.c b/src/driver/main.c index 14762979..a943a95f 100644 --- a/src/driver/main.c +++ b/src/driver/main.c @@ -43,6 +43,7 @@ #include <stdio.h> #include <locale.h> +#include "cfuns.h" #include "utils.h" #define OPENAXIOM_GLOBAL_ENV "AXIOM" diff --git a/src/driver/utils.c b/src/driver/utils.c index 1bf2eccc..1653641f 100644 --- a/src/driver/utils.c +++ b/src/driver/utils.c @@ -403,3 +403,13 @@ openaxiom_execute_core(const openaxiom_command* command, return -1; #endif /* __WIN32__ */ } + + +/* Allocate a vector for ARGC command line arguments. */ +void +openaxiom_allocate_command_argv(openaxiom_command* cmd, int argc) +{ + cmd->core_argc = argc; + cmd->core_argv = (char**) malloc((1 + argc) * sizeof (char*)); + cmd->core_argv[argc] = NULL; +} diff --git a/src/driver/utils.h b/src/driver/utils.h index 30f94912..3f706a88 100644 --- a/src/driver/utils.h +++ b/src/driver/utils.h @@ -80,4 +80,6 @@ void openaxiom_build_rts_options(openaxiom_command*, openaxiom_driver); openaxiom_driver openaxiom_preprocess_arguments(openaxiom_command*, int, char**); +void openaxiom_allocate_command_argv(openaxiom_command*, int); + #endif /* OPENAXIOM_UTILS_INCLUDED */ diff --git a/src/interp/int-top.boot b/src/interp/int-top.boot index 2ac19f7e..ca52a829 100644 --- a/src/interp/int-top.boot +++ b/src/interp/int-top.boot @@ -111,6 +111,16 @@ intloop () == resetStackLimits() mode := CATCH($intTopLevel, SpadInterpretStream(1, nil, true)) +++ If the interpreter is spwan by the session manager, then +++ each successful connection also creates its own frame. +++ In particular, the only time we get to do anything in the `initial' +++ frame is when we get the first connection. In that case, we would +++ be asked by the session manager to create a frame. The client is +++ not aware of that, It is therefore confusing to display a prompt, +++ because all this horse-threading happens behind the client's back. +printFirstPrompt?() == + $interpreterFrameName ~= "initial" or + getOptionValue '"role" ~= '"server" SpadInterpretStream(str, source, interactive?) == pile? := not interactive? @@ -132,9 +142,9 @@ SpadInterpretStream(str, source, interactive?) == $promptMsg : local := 'S2CTP023 interactive? => - not $leanMode and printPrompt() - intloopReadConsole('"", str) - [] + not $leanMode and printFirstPrompt?() and printPrompt() + intloopReadConsole('"", str) + [] intloopInclude (source,0) [] diff --git a/src/sman/sman.c b/src/sman/sman.c index 0b2cc8e6..0dcbcbbb 100644 --- a/src/sman/sman.c +++ b/src/sman/sman.c @@ -64,21 +64,21 @@ static void set_up_defaults(void); static void process_options(openaxiom_command*, int, char**); static void death_handler(int); static void sman_catch_signals(void); -static void fix_env(char** , int); +static void fix_env(int); static void init_term_io(void); static char* strPrefix(char* , char*); static void check_spad_proc(char* , char*); static void clean_up_old_sockets(void); static SpadProcess* fork_you(int); -static void exec_command_env(char* , char**); +static void exec_command_env(char*); static SpadProcess* spawn_of_hell(char* , int); static void start_the_spadclient(void); static void start_the_local_spadclient(void); static void start_the_session_manager(void); static void start_the_hypertex(void); static void start_the_graphics(void); -static void fork_Axiom(void); -static void start_the_Axiom(char**); +static void fork_Axiom(openaxiom_command*); +static void start_the_Axiom(openaxiom_command*); static void clean_up_sockets(void); static void clean_hypertex_socket(void); static void read_from_spad_io(int); @@ -90,6 +90,9 @@ static void kill_all_children(void); static void clean_up_terminal(void); static void monitor_children(void); +/* System defined pointer to array or environment variables. */ +extern char** environ; + char *ws_path; /* location of the core executable */ int start_clef; /* start clef under spad */ int start_graphics; /* start the viewman */ @@ -140,7 +143,6 @@ unsigned char _INTR, _QUIT, _ERASE, _KILL, _EOF, _EOL, _RES1, _RES2; int ptsNum, ptcNum; char ptsPath[20]; -char **new_envp; /* new environment for the core executable */ int child_pid; /* child's process id */ struct termios oldbuf; /* the original settings */ struct termios childbuf; /* terminal structure for user i/o */ @@ -300,18 +302,12 @@ sman_catch_signals(void) } static void -fix_env(char **envp, int spadnum) +fix_env(int spadnum) { - int len, i; - char *sn; - for(len = 0; envp[len] != NULL; len++); - new_envp = (char **) malloc((len + 3) * sizeof(char *)); - new_envp[0] = "SPADSERVER=TRUE"; - sn = (char *) malloc(20 * sizeof(char)); - sprintf(sn, "SPADNUM=%d", spadnum); - new_envp[1] = sn; - for(i=0; i<=len; i++) - new_envp[i+2] = envp[i]; + char sn[20]; + sprintf(sn, "%d", spadnum); + oa_setenv("SPADNUM", sn); + oa_setenv("SPADSERVER", "TRUE"); } static void @@ -407,11 +403,11 @@ fork_you(int death_action) } static void -exec_command_env(char *command,char ** env) +exec_command_env(char *command) { char new_command[512]; sprintf(new_command, "exec %s", command); - execle("/bin/sh","/bin/sh", "-c", new_command, (char*)NULL, env); + execle("/bin/sh","/bin/sh", "-c", new_command, (char*)NULL, environ); } static SpadProcess * @@ -422,7 +418,7 @@ spawn_of_hell(char *command, int death_action) proc->command = command; return proc; } - exec_command_env(command, new_envp); + exec_command_env(command); return NULL; } @@ -487,10 +483,8 @@ start_the_graphics(void) /* Start the core executable session in a separate process, */ /* using a pseudo-terminal to catch all input and output */ static void -fork_Axiom(void) +fork_Axiom(openaxiom_command* cmd) { - char augmented_ws_path[256]; /* will append directory path */ - char *tmp_pointer; SpadProcess *proc; proc = fork_you(Die); @@ -542,22 +536,18 @@ fork_Axiom(void) perror("setting the term buffer"); exit(-1); } - strcpy(augmented_ws_path,ws_path); /* write the name */ - strcat(augmented_ws_path," "); /* space */ - strcat(augmented_ws_path,ws_path); /* name again */ - tmp_pointer = (char *) - strrchr(augmented_ws_path,'/'); /*pointer to last / */ - *(++tmp_pointer) = '\0'; - exec_command_env(augmented_ws_path, new_envp); - - /* fprintf(stderr, "Cannot execute the %s system.\n", ws_path); */ - exit(0); + /* Tell the Core that it is being invoked in server mode. */ + openaxiom_allocate_command_argv(cmd, 2); + cmd->core_argv[0] = + openaxiom_make_path_for(cmd->root_dir, openaxiom_core_driver); + cmd->core_argv[1] = "--role=server"; + openaxiom_execute_core(cmd, openaxiom_core_driver); } } static void -start_the_Axiom(char **envp) +start_the_Axiom(openaxiom_command* cmd) { server_num = make_server_number(); clean_up_old_sockets(); @@ -569,8 +559,8 @@ start_the_Axiom(char **envp) perror("start_the_Axiom: ptyopen failed"); exit(-1); } - fix_env(envp, server_num); - fork_Axiom(); + fix_env(server_num); + fork_Axiom(cmd); close(ptsNum); } @@ -777,7 +767,7 @@ monitor_children(void) } int -main(int argc, char *argv[],char *envp[]) +main(int argc, char *argv[]) { openaxiom_command command = { }; command.root_dir = openaxiom_get_systemdir(argc, argv); @@ -788,7 +778,7 @@ main(int argc, char *argv[],char *envp[]) bsdSignal(SIGINT, SIG_IGN,RestartSystemCalls); init_term_io(); init_spad_process_list(); - start_the_Axiom(envp); + start_the_Axiom(&command); if (open_server(SessionIOName) == -2) { fprintf(stderr, "Fatal error opening I/O socket\n"); clean_up_sockets(); |