Compare commits
1 Commits
fix/editor
...
fix/client
| Author | SHA1 | Date | |
|---|---|---|---|
|
756d4e18cf
|
@@ -522,7 +522,7 @@ accounts_set_script_start(const char* const account_name, const char* const valu
|
|||||||
void
|
void
|
||||||
accounts_set_client(const char* const account_name, const char* const value)
|
accounts_set_client(const char* const account_name, const char* const value)
|
||||||
{
|
{
|
||||||
_accounts_set_string_option(account_name, "client.name", value);
|
_accounts_set_string_option(account_name, "client.account_name", value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -576,7 +576,7 @@ accounts_clear_script_start(const char* const account_name)
|
|||||||
void
|
void
|
||||||
accounts_clear_client(const char* const account_name)
|
accounts_clear_client(const char* const account_name)
|
||||||
{
|
{
|
||||||
_accounts_clear_string_option(account_name, "client.name");
|
_accounts_clear_string_option(account_name, "client.account_name");
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|||||||
@@ -25,8 +25,6 @@
|
|||||||
#include "ui/ui.h"
|
#include "ui/ui.h"
|
||||||
#include "xmpp/xmpp.h"
|
#include "xmpp/xmpp.h"
|
||||||
|
|
||||||
extern char** environ;
|
|
||||||
|
|
||||||
typedef struct EditorContext
|
typedef struct EditorContext
|
||||||
{
|
{
|
||||||
gchar* filename;
|
gchar* filename;
|
||||||
@@ -142,22 +140,6 @@ launch_editor(gchar* initial_content, void (*callback)(gchar* content, void* dat
|
|||||||
GSource* sigchld_warmup = g_child_watch_source_new(getpid());
|
GSource* sigchld_warmup = g_child_watch_source_new(getpid());
|
||||||
g_source_unref(sigchld_warmup);
|
g_source_unref(sigchld_warmup);
|
||||||
|
|
||||||
// Build the editor's env without LINES/COLUMNS pre-fork, so the child only
|
|
||||||
// reassigns environ instead of calling unsetenv() between fork and exec.
|
|
||||||
// The editor's (n)curses then reads the live window via ioctl(TIOCGWINSZ).
|
|
||||||
gsize env_len = 0;
|
|
||||||
while (environ[env_len]) {
|
|
||||||
env_len++;
|
|
||||||
}
|
|
||||||
gchar** editor_env = g_new0(gchar*, env_len + 1);
|
|
||||||
gsize env_kept = 0;
|
|
||||||
for (gsize i = 0; i < env_len; i++) {
|
|
||||||
if (g_str_has_prefix(environ[i], "LINES=") || g_str_has_prefix(environ[i], "COLUMNS=")) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
editor_env[env_kept++] = environ[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
pid_t pid = fork();
|
pid_t pid = fork();
|
||||||
if (pid == -1) {
|
if (pid == -1) {
|
||||||
log_error("[Editor] Failed to fork: %s", strerror(errno));
|
log_error("[Editor] Failed to fork: %s", strerror(errno));
|
||||||
@@ -166,15 +148,12 @@ launch_editor(gchar* initial_content, void (*callback)(gchar* content, void* dat
|
|||||||
ui_resize();
|
ui_resize();
|
||||||
cons_show_error("Failed to start editor: %s", strerror(errno));
|
cons_show_error("Failed to start editor: %s", strerror(errno));
|
||||||
g_strfreev(editor_argv);
|
g_strfreev(editor_argv);
|
||||||
g_free(editor_env); // array only; strings are borrowed from environ
|
|
||||||
g_free(ctx->filename);
|
g_free(ctx->filename);
|
||||||
g_free(ctx);
|
g_free(ctx);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
} else if (pid == 0) {
|
} else if (pid == 0) {
|
||||||
// Child process: Inherits TTY from parent
|
// Child process: Inherits TTY from parent
|
||||||
|
|
||||||
environ = editor_env; // live TIOCGWINSZ size, not the inherited LINES/COLUMNS
|
|
||||||
|
|
||||||
// SIGTSTP=SIG_DFL lets vim's :stop / Ctrl-Z work; profanity catches
|
// SIGTSTP=SIG_DFL lets vim's :stop / Ctrl-Z work; profanity catches
|
||||||
// the STOPPED state via editor_check_stopped() and drops to the shell.
|
// the STOPPED state via editor_check_stopped() and drops to the shell.
|
||||||
signal(SIGINT, SIG_DFL);
|
signal(SIGINT, SIG_DFL);
|
||||||
@@ -191,7 +170,6 @@ launch_editor(gchar* initial_content, void (*callback)(gchar* content, void* dat
|
|||||||
editor_pid = pid;
|
editor_pid = pid;
|
||||||
g_child_watch_add((GPid)pid, _editor_exit_cb, ctx);
|
g_child_watch_add((GPid)pid, _editor_exit_cb, ctx);
|
||||||
g_strfreev(editor_argv);
|
g_strfreev(editor_argv);
|
||||||
g_free(editor_env); // frees the parent's array only; the child keeps its own COW copy until execvp
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user