From 6b3f557daaae17f4572fd7e850767f5c607a3caa Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Thu, 12 Nov 2026 11:50:55 +0100 Subject: spawn-terminal: spawn with all the original command line options Before this, spawn-terminal would spawn a new foot or footclient, but *without* any of the command line options the user started the original foot/footclient with. We did have a hack for --config, but all other options were forgotten in the new instance. This patch fixes this. * term_init() stores the raw argc/argv in the terminal struct. * term_spawn_new() calls spawn() with the stored argc/argv. * for single instances, main() calls term_init() with the unparsed argc/argv. * the client/server protocol is extended to always send the raw argc/argv to the server. * the server calls term_init() with the argc/argv from the client. * bonus: on linux, we now use /proc/self/exe to determine which binary to launch. This means if you run e.g. a foot from your build tree, spawn-terminal will exec _that_ foot, not the system foot. A couple of behavioral changes, and/or side-effects, caused by the above (not exhaustive): * footclient -E: spawn-terminal will not use the _exact_ environment from the original footclient, but will simply pass -E to the new footclient. This means the new instance will inherit the *current* environment of the original instance. * foot htop: spawn-instance will _also_ launch a new foot+htop. Before this patch, spawn-instance would launch a new foot+shell. Closes #1622 --- terminal.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'terminal.h') diff --git a/terminal.h b/terminal.h index 32145cac..3b5bef7e 100644 --- a/terminal.h +++ b/terminal.h @@ -836,6 +836,10 @@ struct terminal { bool grapheme_shaping; bool size_notifications; + + /* For spawn-terminal */ + int argc; + char **argv; }; struct config; @@ -843,7 +847,8 @@ struct terminal *term_init( const struct config *conf, struct fdm *fdm, struct reaper *reaper, struct wayland *wayl, const char *foot_exe, const char *cwd, const char *token, const char *pty_path, - int argc, char *const *argv, const char *const *envp, + int slave_argc, char *const *slave_argv, const char *const *slave_envp, + int foot_argc, const char *const *foot_argv, void (*shutdown_cb)(void *data, int exit_code), void *shutdown_data); bool term_shutdown(struct terminal *term); -- cgit v1.3