else if (strcmp(argv[n], "--console") == 0) {
console_mode = 1;
detach_session = 0;
- console_input = dup(STDIN_FILENO);
- console_output = dup(STDOUT_FILENO);
} else if(strncmp(argv[n], "--user",6) == 0) {
fprintf(stderr, "USING USER OPTION\n");
if ((eq = strchr(argv[n], '='))) {
console_user = eq + 1;
console_mode = 1;
detach_session = 0;
- console_input = dup(STDIN_FILENO);
- console_output = dup(STDOUT_FILENO);
} else {
if (n + 1 >= argc) {
fprintf(stderr, "%s: --user needs a user to log into.\n", argv[0]);
/* Assume console mode & non-session */
console_mode = 1;
detach_session = 0;
- console_input = dup(STDIN_FILENO);
- console_output = dup(STDOUT_FILENO);
}
} else if (strncmp(argv[n], "--pid-file", 10) == 0) {
if ((eq = strchr(argv[n], '=')))
* Eventually we'll conver the config file to a big lua script, so we'll start the lua envionrment before it */
mush_lua_start();
+ /* decide if we're in @shutdown/reboot
+ * This has to be done before init_game_config() to avoid stdin and stdout
+ * being closed before we need them. */
+ restarting = 0;
+ newerr = fopen(REBOOTFILE, "r");
+ if (newerr) {
+ restarting = 1;
+ fclose(newerr);
+ }
+
+ if (console_mode && !restarting) {
+ console_input = dup(STDIN_FILENO);
+ console_output = dup(STDOUT_FILENO);
+ }
+
init_game_config(confname);
/* save a file descriptor */
extrafd = open("/dev/null", O_RDWR);
#endif
- /* decide if we're in @shutdown/reboot */
- restarting = 0;
- newerr = fopen(REBOOTFILE, "r");
- if (newerr) {
- restarting = 1;
- fclose(newerr);
- }
-
/* load databases */
if (init_game_dbs() < 0) {
do_rawlog(LT_ERR, T("ERROR: Couldn't load databases! Exiting."));
unsigned long input_ready, output_ready;
int notify_fd = -1;
- if (console_mode) {
- if (console_input >= maxd)
- maxd = console_input + 1;
- if (console_output >= maxd)
- maxd = console_output + 1;
+ if (!restarting) {
+ if (console_mode) {
+ if (console_input >= maxd)
+ maxd = console_input + 1;
+ if (console_output >= maxd)
+ maxd = console_output + 1;
- initializesock(console_input, console_output, "localhost", "127.0.0.1", 0);
+ initializesock(console_input, console_output, "localhost", "127.0.0.1", 0);
- sock = 0;
+ sock = 0;
#ifdef HAS_OPENSSL
- sslsock = 0;
+ sslsock = 0;
#endif
- } else if (!restarting) {
- sock = make_socket(port, SOCK_STREAM, NULL, NULL, MUSH_IP_ADDR);
- if (sock >= maxd)
- maxd = sock + 1;
+ } else {
+ sock = make_socket(port, SOCK_STREAM, NULL, NULL, MUSH_IP_ADDR);
+ if (sock >= maxd)
+ maxd = sock + 1;
#ifdef HAS_OPENSSL
- if (sslport) {
- sslsock = make_socket(sslport, SOCK_STREAM, NULL, NULL, SSL_IP_ADDR);
- ssl_master_socket = ssl_setup_socket(sslsock);
- if (sslsock >= maxd)
- maxd = sslsock + 1;
- }
+ if (sslport) {
+ sslsock = make_socket(sslport, SOCK_STREAM, NULL, NULL, SSL_IP_ADDR);
+ ssl_master_socket = ssl_setup_socket(sslsock);
+ if (sslsock >= maxd)
+ maxd = sslsock + 1;
+ }
#endif
+ }
}
our_gettimeofday(&last_slice);
DESC *d;
SU_PATH *exit_path;
long flags = RDBF_SCREENSIZE | RDBF_TTYPE | RDBF_PUEBLO_CHECKSUM
- | RDBF_SU_EXIT_PATH | RDBF_OUTDESC;
+ | RDBF_SU_EXIT_PATH | RDBF_CONSOLE;
if (setjmp(db_err)) {
flag_broadcast(0, 0, T("GAME: Error writing reboot database!"));
exit(0);
penn_fprintf(f, "V%ld\n", flags);
putref(f, sock);
putref(f, maxd);
+ putref(f, console_input);
+ putref(f, console_output);
/* First, iterate through all descriptors to get to the end
* we do this so the descriptor_list isn't reversed on reboot
*/
if (val > maxd)
maxd = val;
+ if (flags & RDBF_CONSOLE) {
+ console_input = getref(f);
+ console_output = getref(f);
+ }
+
while ((val = getref(f)) != 0) {
ndescriptors++;
d = (DESC *) mush_malloc(sizeof(DESC), "descriptor");
d->descriptor = val;
- if (flags & RDBF_OUTDESC)
+ if (flags & RDBF_CONSOLE)
d->outdesc = getref(f);
d->input_handler = do_command;
d->connected_at = getref(f);
args[n++] = saved_argv[0];
args[n++] = "--no-session";
+ if (console_mode)
+ args[n++] = "--console";
if (pidfile) {
args[n++] = "--pid-file";
args[n++] = pidfile;