Merge remote-tracking branch 'refs/remotes/tmux-openbsd/master'

* refs/remotes/tmux-openbsd/master:
  build: don't exit
  build: always attempt portable merge
  build: capture openbsd-base before filtering
  build: fetch cutover master before merge
  Use _exit in child after fork, from Yayo Razo in GitHub issue 5376.
  Add missing calloc check and use fatal. Prompted by a similar change from Yayo Razo.
  actions: use published openbsd-git as base update
  github actions: automate updates
  Do not make pty fds blocking again until all the data has been consumed or control mode clients can get stuck, GitHub issue 5356 from Ben Maurer.
  Add formats and events for OSC 133 commmands, as well as a -T flag to set-hook -B to only fire when the format is true.
  Replace the notification system with events. Events can carry a payload of additional payload (to reduce problems with lifetime of objects) and are delivered to one or more event sinks. This is more powerful and reduces the complex dependencies between control mode and hooks. Events are now used for hooks, control mode notifications and for monitors (set-hook -B).
This commit is contained in:
Thomas Adam
2026-07-13 09:22:25 +01:00
147 changed files with 2986 additions and 996 deletions

49
spawn.c
View File

@@ -1,4 +1,4 @@
/* $OpenBSD$ */
/* $OpenBSD: spawn.c,v 1.47 2026/07/10 13:38:45 nicm Exp $ */
/*
* Copyright (c) 2019 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -71,6 +71,45 @@ spawn_log(const char *from, struct spawn_context *sc)
log_debug("%s: s=$%u %s idx=%d", from, s->id, tmp, sc->idx);
}
static void
spawn_fire_pane_created(struct spawn_context *sc, struct window_pane *wp)
{
struct event_payload *ep;
struct cmd_find_state fs;
char *cmd = NULL;
const char *cwd = wp->cwd;
ep = event_payload_create();
cmd_find_from_winlink_pane(&fs, sc->wl, wp, 0);
event_payload_set_target(ep, &fs);
event_payload_set_session(ep, "session", sc->s);
event_payload_set_window(ep, "window", wp->window);
event_payload_set_int(ep, "window_index", sc->wl->idx);
event_payload_set_pane(ep, "pane", wp);
if (wp->argc != 0)
cmd = cmd_stringify_argv(wp->argc, wp->argv);
if (cmd != NULL && *cmd != '\0')
event_payload_set_string(ep, "pane_command", "%s", cmd);
else if (wp->shell != NULL)
event_payload_set_string(ep, "pane_command", "%s", wp->shell);
free(cmd);
if (cwd != NULL)
event_payload_set_string(ep, "pane_current_path", "%s", cwd);
if (sc->flags & SPAWN_EMPTY)
event_payload_set_int(ep, "created_empty", 1);
else
event_payload_set_int(ep, "created_empty", 0);
if (sc->flags & SPAWN_RESPAWN)
event_payload_set_int(ep, "created_respawn", 1);
else
event_payload_set_int(ep, "created_respawn", 0);
events_fire("pane-created", ep);
}
struct winlink *
spawn_window(struct spawn_context *sc, char **cause)
{
@@ -131,7 +170,7 @@ spawn_window(struct spawn_context *sc, char **cause)
* if this makes it empty.
*/
wl->flags &= ~WINLINK_ALERTFLAGS;
notify_session_window("window-unlinked", s, wl->window);
events_fire_winlink("window-unlinked", wl);
winlink_stack_remove(&s->lastw, wl);
winlink_remove(&s->windows, wl);
@@ -191,7 +230,7 @@ spawn_window(struct spawn_context *sc, char **cause)
/* Fire notification if new window. */
if (~sc->flags & SPAWN_RESPAWN)
notify_session_window("window-linked", s, w);
events_fire_winlink("window-linked", sc->wl);
session_group_synchronize_from(s);
return (sc->wl);
@@ -519,8 +558,8 @@ complete:
sigprocmask(SIG_SETMASK, &oldset, NULL);
window_pane_set_event(new_wp);
environ_free(child);
spawn_fire_pane_created(sc, new_wp);
if (sc->flags & SPAWN_RESPAWN)
return (new_wp);
@@ -531,7 +570,7 @@ complete:
window_set_active_pane(w, new_wp, 1);
}
if (~sc->flags & SPAWN_NONOTIFY)
notify_window("window-layout-changed", w);
events_fire_window("window-layout-changed", w);
return (new_wp);
}