<feed xmlns='http://www.w3.org/2005/Atom'>
<title>mirrors/foot.git/slave.c, branch 1.20.2</title>
<subtitle>A fast, lightweight and minimalistic Wayland terminal emulator</subtitle>
<id>https://git.0x0f.dev/mirrors/foot.git/atom?h=1.20.2</id>
<link rel='self' href='https://git.0x0f.dev/mirrors/foot.git/atom?h=1.20.2'/>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/'/>
<updated>2024-08-09T11:55:21Z</updated>
<entry>
<title>slave: prefix user notifications with 'foot'</title>
<updated>2024-08-09T11:55:21Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2024-08-09T11:55:21Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=7e1894978fda263f823abbb1e66ea251e96bfd83'/>
<id>urn:sha1:7e1894978fda263f823abbb1e66ea251e96bfd83</id>
<content type='text'>
To make it clearer _who_ is emitting the warning/errors
</content>
</entry>
<entry>
<title>xmalloc: remove delim param from xstrjoin() and add separate xstrjoin3()</title>
<updated>2024-08-03T07:51:06Z</updated>
<author>
<name>Craig Barnes</name>
<email>craigbarnes@protonmail.com</email>
</author>
<published>2024-08-03T07:12:13Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=f87c9bb9f70f1a6c8c7081c762c15ba7eaaf971e'/>
<id>urn:sha1:f87c9bb9f70f1a6c8c7081c762c15ba7eaaf971e</id>
<content type='text'>
This avoids the need for an unused third argument for most xstrjoin()
calls and replaces the cases where it's needed with a more flexible
function. Code generation is the same in both cases, when there are 2
string params and a compile-time known delimiter.

This commit also converts 4 uses of xasprintf() to use xstrjoin*().

See also: https://godbolt.org/z/xsjrhv9b6
</content>
</entry>
<entry>
<title>Remove a number of unused includes</title>
<updated>2024-08-02T06:28:13Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2024-08-01T18:11:04Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=a9e462d952ca1e0367e9e6eb6ee00a0cda7e8c9b'/>
<id>urn:sha1:a9e462d952ca1e0367e9e6eb6ee00a0cda7e8c9b</id>
<content type='text'>
</content>
</entry>
<entry>
<title>meson: auto-detect execvpe on FreeBSD</title>
<updated>2024-06-07T14:31:11Z</updated>
<author>
<name>Jan Beich</name>
<email>jbeich@FreeBSD.org</email>
</author>
<published>2024-05-25T12:40:25Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=f67449700b169dfab971773530ca8268448d4fbd'/>
<id>urn:sha1:f67449700b169dfab971773530ca8268448d4fbd</id>
<content type='text'>
https://github.com/freebsd/freebsd-src/commit/0667d0e0e365
</content>
</entry>
<entry>
<title>util: add streq() function and use in place of strcmp(...) == 0</title>
<updated>2024-02-05T11:09:52Z</updated>
<author>
<name>Craig Barnes</name>
<email>craigbarnes@protonmail.com</email>
</author>
<published>2024-01-24T23:17:28Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=e0f3703ae6c4084f9275cfc78d87e5604cc27a10'/>
<id>urn:sha1:e0f3703ae6c4084f9275cfc78d87e5604cc27a10</id>
<content type='text'>
</content>
</entry>
<entry>
<title>slave: fix typo</title>
<updated>2024-01-16T20:40:35Z</updated>
<author>
<name>Artturin</name>
<email>Artturin@artturin.com</email>
</author>
<published>2024-01-16T20:40:35Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=8073ad352b6f6034a648b1a4331d9ccabbddbf82'/>
<id>urn:sha1:8073ad352b6f6034a648b1a4331d9ccabbddbf82</id>
<content type='text'>
```
../slave.c: In function 'slave_spawn':
../slave.c:441:21: error: 'custom_envp' undeclared (first use in this function); did you mean 'custom_env'?
  441 |         add_to_env(&amp;custom_envp, "TERMINFO", FOOT_TERMINFO_PATH);
      |                     ^~~~~~~~~~~
      |                     custom_env
../slave.c:441:21: note: each undeclared identifier is reported only once for each function it appears in
```
</content>
</entry>
<entry>
<title>slave: don't skip setting environment variables when using a custom environment</title>
<updated>2024-01-11T15:37:17Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2024-01-09T15:50:47Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=9da7152f834384a354710fcc8f99a6f83e5dfc12'/>
<id>urn:sha1:9da7152f834384a354710fcc8f99a6f83e5dfc12</id>
<content type='text'>
When launching footclient with -E,--client-environment the environment
variables that should be set by foot, wasn't.

Those variables are:

* TERM
* COLORTERM
* PWD
* SHELL

and all variables defined by the user in the [environment] section in
foot.ini.

In the same way, we did not *unset* TERM_PROGRAM and
TERM_PROGRAM_VERSION.

This patch fixes it by "cloning" the custom environment, making it
mutable, and then adding/removing the variables above from it.

Instead of calling setenv()/unsetenv() directly, we add the wrapper
functions add_to_env() and del_from_env().

When *not* using a custom environment, they simply call
setenv()/unsetenv().

When we *are* using a custom environment, add_to_env() first loops all
existing variables, looking for a match. If a match is found, it's
updated with the new value. If it's not found, a new entry is added.

del_from_env() loops all entries, and removes it when a match is
found. If no match is found, nothing is done.

The mutable environment is allocated on the heap, but never free:d. We
don't need to free it, since it's only allocated after forking, in the
child process.

Closes #1568
</content>
</entry>
<entry>
<title>slave: ignore return value of chdir()</title>
<updated>2024-01-05T07:12:32Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2024-01-05T07:12:32Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=0ca46338986becfbbc24160083a9620e8f29a7ca'/>
<id>urn:sha1:0ca46338986becfbbc24160083a9620e8f29a7ca</id>
<content type='text'>
It's not critical.

Fixes

    ../slave.c: In function ‘slave_spawn’:
    ../slave.c:410:9: error: ignoring return value of ‘chdir’ declared with attribute ‘warn_unused_result’ [-Werror=unused-result]
      410 |         chdir("/");
          |         ^~~~~~~~~~
</content>
</entry>
<entry>
<title>slave: chdir to / after spawning the client application</title>
<updated>2024-01-03T13:07:15Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2024-01-03T13:07:15Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=66f25bb4346eab9b7914213343d22ee67c57724f'/>
<id>urn:sha1:66f25bb4346eab9b7914213343d22ee67c57724f</id>
<content type='text'>
With this patch, the terminal process now changes PWD to / after
spawning the client application.

This ensures the terminal process itself does not "lock" a
directory. For example, we may keep a mount point from being
unmounted.

Closes #1528
</content>
</entry>
<entry>
<title>slave: unset TERM_PROGRAM{,_VERSION}</title>
<updated>2023-05-18T15:50:48Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2023-05-12T12:55:55Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=a2f765b72a6612758a034a5b0c24ec08625db1a3'/>
<id>urn:sha1:a2f765b72a6612758a034a5b0c24ec08625db1a3</id>
<content type='text'>
Foot’s policy is to not set environment variables that identifies
it (except the well-known and established `TERM` variable).

We encourage applications to use terminfo to determine capabilities,
or terminal queries, when available. Or, at least use terminal queries
to detect the terminal and its version.

Setting environment variables is a bad idea since they are inherited
by all applications started by the terminal (which is the whole
point). But, this includes other terminal emulators, making it very
possible a terminal emulator gets mis-detected just because it was
started from another terminal.

Since there are a couple of terminal emulators that _do_ set
TERM_PROGRAM and TERM_PROGRAM_VERSION, unset these environment
variables to avoid being misdetected.

Closes #1349
</content>
</entry>
<entry>
<title>slave: set $TERM_PROGRAM and $TERM_PROGRAM_VERSION environment variables</title>
<updated>2023-03-20T14:40:36Z</updated>
<author>
<name>Craig Barnes</name>
<email>craigbarnes@protonmail.com</email>
</author>
<published>2023-03-20T14:40:36Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=5b2f02d826d8043b6b89860c56802ea5fed0f3bd'/>
<id>urn:sha1:5b2f02d826d8043b6b89860c56802ea5fed0f3bd</id>
<content type='text'>
These are already being set by iTerm2, WezTerm, tmux and likely some
others. Even though using yet more environment variables seems rather
questionable, if we don't set these we run the risk of inheriting them
from other terminals.

See also:

* https://gitlab.com/gnachman/iterm2/-/blob/97a6078df8e822da165e91737a01c0b9e115dd16/sources/PTYSession.m#L2568-2570
* https://github.com/tmux/tmux/blob/1d0f68dee9f71c504e03616fa472a408a6caa49b/environ.c#L263-L264
* https://github.com/search?q=TERM_PROGRAM&amp;type=code
</content>
</entry>
<entry>
<title>slave: unsetenv() env vars that have been set to the empty string</title>
<updated>2022-12-06T18:36:15Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2022-12-01T18:43:38Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=ccfb953bb020a1d229490b8a3e7790ed5c7e1752'/>
<id>urn:sha1:ccfb953bb020a1d229490b8a3e7790ed5c7e1752</id>
<content type='text'>
That is, users can now *clear* environment variables by doing:

  [environment]
  VAR=””

Note that the quotes are required.

Closes #1225
</content>
</entry>
<entry>
<title>slave: spawn: set PWD environment variable</title>
<updated>2022-10-02T18:11:07Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2022-09-26T17:00:27Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=9e5866109374a3181da06ad411b15bab4a728d8e'/>
<id>urn:sha1:9e5866109374a3181da06ad411b15bab4a728d8e</id>
<content type='text'>
This improves handling of symlinks (in CWD) when launching a new
terminal instance, either through ctrl+shift+n, or using the
--working-directory command line option.

Closes #1179
</content>
</entry>
<entry>
<title>config: add a new ‘environment’ section</title>
<updated>2022-06-13T09:55:23Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2022-05-28T17:27:29Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=755f96321ab47f931d11680027d47d1d772f5584'/>
<id>urn:sha1:755f96321ab47f931d11680027d47d1d772f5584</id>
<content type='text'>
This section allows the user to define custom environment variables to
be set in the child process:

  [environment]
  name=value
</content>
</entry>
<entry>
<title>slave: roll our own ‘execvpe()’ on FreeBSD</title>
<updated>2022-04-12T13:07:41Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2022-04-11T12:02:18Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=b3d0cdd4b20855c62a759b66da94907f6bf81cb7'/>
<id>urn:sha1:b3d0cdd4b20855c62a759b66da94907f6bf81cb7</id>
<content type='text'>
</content>
</entry>
<entry>
<title>client/slave: explictly add ‘extern char **environ’</title>
<updated>2022-04-12T13:07:41Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2022-04-11T11:24:27Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=fd414f79be177b23a67ce87b81657c2bfd80a35e'/>
<id>urn:sha1:fd414f79be177b23a67ce87b81657c2bfd80a35e</id>
<content type='text'>
It’s not in any header files on FreeBSD.
</content>
</entry>
<entry>
<title>client: add -E,--client-environment</title>
<updated>2022-04-12T13:07:40Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2022-04-11T10:19:40Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=d02124902b4e27c3ed3ef48442ce17c5e0af9d56'/>
<id>urn:sha1:d02124902b4e27c3ed3ef48442ce17c5e0af9d56</id>
<content type='text'>
When this option is used, the child process in the new terminal
instance will inherit its environment from the footclient process,
instead of the foot server’s.

Implemented by sending (yet another) dynamic string list as part of
the client -&gt; server setup packet. When the new option is *not* used,
the setup packet is now 2 bytes larger than before.

On the server side, the slave process now uses execvpe() instead of
execvp(). There’s plumbing to propagate a new ‘envp’ argument from
term_init() all the way down to slave_exec(). If ‘envp’ is NULL, we
use ‘environ’ instead (thus matching the old behavior of execvp()).

Closes #1004
</content>
</entry>
<entry>
<title>Explicitly initialize sigaction::sa_mask members with sigemptyset(3)</title>
<updated>2022-02-12T12:26:42Z</updated>
<author>
<name>Craig Barnes</name>
<email>craigbarnes@protonmail.com</email>
</author>
<published>2022-02-12T12:04:57Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=23cf80667a36aaff1865fc50afab3f98a796cf14'/>
<id>urn:sha1:23cf80667a36aaff1865fc50afab3f98a796cf14</id>
<content type='text'>
Not doing so before calling sigaction(3) is "undefined" according to
POSIX[1]:

&gt; Applications shall call either sigemptyset() or sigfillset() at least
&gt; once for each object of type sigset_t prior to any other use of that
&gt; object. If such an object is not initialized in this way, but is
&gt; nonetheless supplied as an argument to any of pthread_sigmask(),
&gt; sigaction(), sigaddset(), sigdelset(), sigismember(), sigpending(),
&gt; sigprocmask(), sigsuspend(), sigtimedwait(), sigwait(), or
&gt; sigwaitinfo(), the results are undefined.

The use of designated initializers means that sa_mask members were
still being initialized, but sigset_t is an opaque type and implicit
initialization doesn't necessarily produce the same results as using
sigemptyset(3) (although it typically does on most implementations).

[1]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/sigaddset.html
</content>
</entry>
<entry>
<title>slave: re-use ‘struct sigaction’ variable when resetting SIGHUP+SIGPIPE</title>
<updated>2021-12-18T22:22:52Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-12-18T22:22:52Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=027603cbb80b2c9aadd71faaaf75e4912a55a9be'/>
<id>urn:sha1:027603cbb80b2c9aadd71faaaf75e4912a55a9be</id>
<content type='text'>
</content>
</entry>
<entry>
<title>slave: restore SIGPIPE</title>
<updated>2021-12-18T22:20:10Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-12-18T22:20:10Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=fb488b61621682d19524c7dba348f7814b7d738f'/>
<id>urn:sha1:fb488b61621682d19524c7dba348f7814b7d738f</id>
<content type='text'>
</content>
</entry>
</feed>
