Revert "I need to take a break. Fixup."
This reverts commit 3e556b984c7769a25b301871bc788daecb6d6d4e. Revert "Further fix the issue and add the assert that'd have prevented it." This reverts commit 056502001eb94f1fc001126738055f6605a6fc21. Revert "Fix actual issue with allow_use_posix_spawn." This reverts commit 85b9f3c71f703429e44290b76e6d9e87b58d31ce. Revert "Stop using posix_spawn when it is not allowed" This reverts commit 9c896e199080bd4e219507961975a0ac97ebc32d. Revert "don't even set up a fish_use_posix_spawn handler if unsupported" This reverts commit 8b14ac4a9c3d0e15f9a7bd16a7633a9d1452b6d9.
This commit is contained in:
parent
3e556b984c
commit
50d37527a9
@ -298,6 +298,8 @@ class env_stack_t final : public environment_t {
|
||||
static env_stack_t &globals();
|
||||
};
|
||||
|
||||
bool get_use_posix_spawn();
|
||||
|
||||
extern bool term_has_xn; // does the terminal have the "eat_newline_glitch"
|
||||
|
||||
/// Returns true if we think the terminal supports setting its title.
|
||||
|
@ -43,7 +43,6 @@
|
||||
#include "input_common.h"
|
||||
#include "maybe.h"
|
||||
#include "output.h"
|
||||
#include "postfork.h"
|
||||
#include "proc.h"
|
||||
#include "reader.h"
|
||||
#include "screen.h"
|
||||
@ -251,8 +250,16 @@ static void handle_curses_change(const environment_t &vars) {
|
||||
init_curses(vars);
|
||||
}
|
||||
|
||||
static constexpr bool allow_use_posix_spawn() {
|
||||
#if defined(FISH_USE_POSIX_SPAWN)
|
||||
/// Whether to use posix_spawn when possible.
|
||||
static relaxed_atomic_bool_t g_use_posix_spawn{false};
|
||||
|
||||
bool get_use_posix_spawn() { return g_use_posix_spawn; }
|
||||
|
||||
extern "C" {
|
||||
const char *gnu_get_libc_version();
|
||||
}
|
||||
|
||||
static bool allow_use_posix_spawn() {
|
||||
// OpenBSD's posix_spawn returns status 127, instead of erroring with ENOEXEC, when faced with a
|
||||
// shebangless script. Disable posix_spawn on OpenBSD.
|
||||
#if defined(__OpenBSD__)
|
||||
@ -264,21 +271,14 @@ static constexpr bool allow_use_posix_spawn() {
|
||||
#else // !defined(__OpenBSD__)
|
||||
return true;
|
||||
#endif
|
||||
#else // !defined(FISH_USE_POSIX_SPAWN)
|
||||
return false;
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
static relaxed_atomic_bool_t g_use_posix_spawn{false};
|
||||
bool get_use_posix_spawn() {
|
||||
assert(allow_use_posix_spawn() && g_use_posix_spawn && "get_use_posix_spawn() called but not allowed");
|
||||
return g_use_posix_spawn;
|
||||
}
|
||||
|
||||
/// Whether to use posix_spawn when possible.
|
||||
static void handle_fish_use_posix_spawn_change(const environment_t &vars) {
|
||||
// If the variable is missing or empty, we default to true if allowed.
|
||||
if (auto var = vars.get(L"fish_use_posix_spawn")) {
|
||||
// Note if the variable is missing or empty, we default to true if allowed.
|
||||
if (!allow_use_posix_spawn()) {
|
||||
g_use_posix_spawn = false;
|
||||
} else if (auto var = vars.get(L"fish_use_posix_spawn")) {
|
||||
g_use_posix_spawn = var->empty() || bool_from_string(var->as_string());
|
||||
} else {
|
||||
g_use_posix_spawn = true;
|
||||
@ -331,9 +331,7 @@ static std::unique_ptr<const var_dispatch_table_t> create_dispatch_table() {
|
||||
var_dispatch_table->add(L"fish_history", handle_fish_history_change);
|
||||
var_dispatch_table->add(L"fish_autosuggestion_enabled", handle_autosuggestion_change);
|
||||
var_dispatch_table->add(L"TZ", handle_tz_change);
|
||||
if (allow_use_posix_spawn()) {
|
||||
var_dispatch_table->add(L"fish_use_posix_spawn", handle_fish_use_posix_spawn_change);
|
||||
}
|
||||
var_dispatch_table->add(L"fish_use_posix_spawn", handle_fish_use_posix_spawn_change);
|
||||
var_dispatch_table->add(L"fish_trace", handle_fish_trace);
|
||||
var_dispatch_table->add(L"fish_cursor_selection_mode",
|
||||
handle_fish_cursor_selection_mode_change);
|
||||
@ -358,7 +356,7 @@ static void run_inits(const environment_t &vars) {
|
||||
guess_emoji_width(vars);
|
||||
update_wait_on_escape_ms(vars);
|
||||
handle_read_limit_change(vars);
|
||||
if (allow_use_posix_spawn()) handle_fish_use_posix_spawn_change(vars);
|
||||
handle_fish_use_posix_spawn_change(vars);
|
||||
handle_fish_trace(vars);
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,4 @@ void env_dispatch_init(const environment_t &vars);
|
||||
/// React to changes in variables like LANG which require running some code.
|
||||
void env_dispatch_var_change(const wcstring &key, env_stack_t &vars);
|
||||
|
||||
/// Whether posix_spawn is configured and/or allowed to be in use globally.
|
||||
bool get_use_posix_spawn();
|
||||
|
||||
#endif
|
||||
|
@ -30,7 +30,6 @@
|
||||
#include "builtin.h"
|
||||
#include "common.h"
|
||||
#include "env.h"
|
||||
#include "env_dispatch.h"
|
||||
#include "exec.h"
|
||||
#include "fallback.h" // IWYU pragma: keep
|
||||
#include "fds.h"
|
||||
|
Loading…
x
Reference in New Issue
Block a user