From a1b151d8d32306a5793f144ee14164c4d3488470 Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Mon, 19 Nov 2001 01:54:02 +0000 Subject: [PATCH] A few more updates. git-svn-id: http://svn.irssi.org/repos/irssi/trunk@2071 dbcabf3a-b0e7-0310-adc4-f8d773084564 --- src/core/session.c | 48 ++++++++++++++++++---------------------------- 1 file changed, 19 insertions(+), 29 deletions(-) diff --git a/src/core/session.c b/src/core/session.c index 1f990972..c773c37d 100644 --- a/src/core/session.c +++ b/src/core/session.c @@ -45,7 +45,7 @@ static void cmd_upgrade(const char *data) GSList *file_handles; const char *args[10]; char *session_file; - int pid, n; + int n; if (*data == '\0') data = irssi_binary; @@ -64,36 +64,26 @@ static void cmd_upgrade(const char *data) config_write(session, NULL, -1); config_close(session); - /* start it .. */ - pid = fork(); - if (pid == -1) - cmd_return_error(CMDERR_ERRNO); + /* Cleanup the terminal etc. */ + signal_emit("session clean", 0); - if (pid == 0) { - /* we're the child - we want to send the server connections - to the new binary here */ - g_free(session_file); - exit(0); - } else { - /* we're the old process - exec() the new binary here so - the TTY won't get lost */ - signal_emit("session clean", 0); - for (n = 3; n < 256; n++) { - if (g_slist_find(file_handles, GINT_TO_POINTER(n)) == NULL) - close(n); - } - g_slist_free(file_handles), - - args[0] = data; - args[1] = "--session"; - args[2] = session_file; - args[3] = "-!"; - args[4] = NULL; - execvp(args[0], (char **) args); - - fprintf(stderr, "exec: %s: %s\n", args[0], g_strerror(errno)); - _exit(-1); + /* close the file handles we don't want to transfer to new client */ + for (n = 3; n < 256; n++) { + if (g_slist_find(file_handles, GINT_TO_POINTER(n)) == NULL) + close(n); } + g_slist_free(file_handles), + + /* irssi --session ~/.irssi/session. -! */ + args[0] = data; + args[1] = "--session"; + args[2] = session_file; + args[3] = "-!"; + args[4] = NULL; + execvp(args[0], (char **) args); + + fprintf(stderr, "exec: %s: %s\n", args[0], g_strerror(errno)); + _exit(-1); } static void session_save_server(SERVER_REC *server, CONFIG_REC *config,