1
0
mirror of https://github.com/irssi/irssi.git synced 2024-12-04 14:46:39 -05:00

A few more updates.

git-svn-id: http://svn.irssi.org/repos/irssi/trunk@2071 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
Timo Sirainen 2001-11-19 01:54:02 +00:00 committed by cras
parent bbbb36cf19
commit a1b151d8d3

View File

@ -45,7 +45,7 @@ static void cmd_upgrade(const char *data)
GSList *file_handles; GSList *file_handles;
const char *args[10]; const char *args[10];
char *session_file; char *session_file;
int pid, n; int n;
if (*data == '\0') if (*data == '\0')
data = irssi_binary; data = irssi_binary;
@ -64,36 +64,26 @@ static void cmd_upgrade(const char *data)
config_write(session, NULL, -1); config_write(session, NULL, -1);
config_close(session); config_close(session);
/* start it .. */ /* Cleanup the terminal etc. */
pid = fork(); signal_emit("session clean", 0);
if (pid == -1)
cmd_return_error(CMDERR_ERRNO);
if (pid == 0) { /* close the file handles we don't want to transfer to new client */
/* we're the child - we want to send the server connections for (n = 3; n < 256; n++) {
to the new binary here */ if (g_slist_find(file_handles, GINT_TO_POINTER(n)) == NULL)
g_free(session_file); close(n);
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);
} }
g_slist_free(file_handles),
/* irssi --session ~/.irssi/session.<pid> -! */
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, static void session_save_server(SERVER_REC *server, CONFIG_REC *config,