Commit graph

43 commits

Author SHA1 Message Date
Jan Beich
e462419e34
slave: skip e310487dae if not supported
slave.c:188:26: error: use of undeclared identifier 'IUTF8'
        flags.c_iflag |= IUTF8;
                         ^
2021-01-23 10:16:29 +01:00
Daniel Eklöf
c779a5ec7d
log: include 'fmt' in __VA_ARGS__
This ensures all calls have at least one __VA_ARGS__ argument, thus
making them ISO C99 compliant.
2020-08-23 10:07:08 +02:00
Craig Barnes
26fccae03d slave: set $COLORTERM environment variable to "truecolor"
This is also done by libvte, alacritty, kitty and several other
terminal emulators as a way to indicate support for 24-bit RGB
colors. It generally also implies support for the xterm 256-color
palette and basic ECMA-48 colors.
2020-08-23 05:33:48 +01:00
Craig Barnes
7a77958ba2 Convert most dynamic allocations to use functions from xmalloc.h 2020-08-08 20:37:57 +01:00
Craig Barnes
11a1d99da7 Replace non-portable "\e" escape in string literals with "\033" 2020-08-02 23:54:04 +01:00
Daniel Eklöf
bae3244ec6
Revert "slave: use an event FD to communicate errors after fork before exec"
This reverts commit 027a8de6f5.

I was a bit quick on this one, and only tested error cases. Turns out,
this causes foot to hang in a blocking read(3) on the event FD.

This is because while the FD has FD_CLOEXEC, that flag is per file
descriptor. I.e. the forked copy of the event fd is closed when we
exec(), but since this isn't a pipe, nothing is signaled to the parent
process, which thus remains blocking in read(3) since its copy of the
event fd hasn't been closed.

We _could_ write a dummy value on the event fd just before exec(), but
then we wouldn't be able to catch errors from exec() self - only
errors *before* exec().
2020-08-01 09:41:31 +02:00
Daniel Eklöf
027a8de6f5
slave: use an event FD to communicate errors after fork before exec
Replace the pipe we used to communicate errors after fork(), but
before exec() to the parent process with an event FD.

The overhead in the kernel is much lower to setup an event fd,
compared to a pipe.
2020-08-01 09:33:43 +02:00
Daniel Eklöf
c8e78674ed
slave: emit user-notifications before dup:ing stdin/stdout/stderr
Since we need to restore the status flags anyway, there's nothing to
gain from emitting the user notifications after dup:ing the pts file
descriptor.

On the other hand, emitting user notifications *before* dup:ing means
we can still print error messages for e.g. write(3) errors.
2020-08-01 09:00:18 +02:00
Daniel Eklöf
7e93405b1a
slave: user-notifications: skip the O_NONBLOCK dance when there aren't any notifications 2020-07-31 19:52:50 +02:00
Daniel Eklöf
1da8142f32
slave: restore pts file status flags after emitting user-notifications
We (need to) set O_NONBLOCK on the pts file description before
emitting the user-notifications, to ensure we don't block in write(3).

However, since file status flags are per *file*, not per
file *descriptor*, this ends up setting O_NONBLOCK on the dup:ed
stdin/stdout/stderr file descriptors too.

Not all clients want this, or can handle this.

Thus we need to restore the original flags before exec:ing the client.

This fixes "makepkg" build failures.
2020-07-31 18:13:00 +02:00
Daniel Eklöf
a7d21c5c7f
slave: user-notifications: don't block in write(3)
The main process is blocking and waiting for us to close the error
pipe (in exec(3), via O_CLOEXEC).

Thus, pts data will *not* be processed until we've exec:d the shell.

Because of this we must not write too much and block in write(3). Do
this by setting O_NONBLOCK on the pts fd (*after* dup:ing it to
stdin/stderr/sdout) and watch for EAGAIN EWOULDBLOCK.
2020-07-31 17:15:51 +02:00
Daniel Eklöf
b661513245
slave: user-notifications: emit errors first, then warnings and last deprecations 2020-07-31 17:10:39 +02:00
Daniel Eklöf
f6533a71e4
user-notification: 'productify' the user-warning system
* Rename user_warning to user_notification
* Add warning and error types (in addition to the existing deprecated)
* Simplify logic when emitting a user notification after forking; we
  don't need to copy the notification data since we're in a new
  process and have total control over that memory.
2020-07-30 18:58:54 +02:00
Daniel Eklöf
113759b0a9
slave: don't ignore write(3) errors 2020-07-29 19:46:20 +02:00
Daniel Eklöf
b3d0215c38
term: add capability to print warnings *inside* the terminal
This is intended to be used to print e.g. deprecation warnings inside
the terminal, *before* the shell is started.
2020-07-29 19:42:12 +02:00
Daniel Eklöf
e310487dae
slave: set IUTF8 2020-05-26 18:18:11 +02:00
Daniel Eklöf
c605503df6
slave: restore signal mask 2020-05-21 20:22:24 +02:00
Daniel Eklöf
e654cf3880
slave: configure pts to be the controlling terminal of the forked process 2020-05-13 13:07:44 +02:00
Daniel Eklöf
6912bbd310
slave: set $SHELL when command line is a shell listed in /etc/shells 2020-03-02 18:46:35 +01:00
Daniel Eklöf
f1b1ac39f6
slave: check return value of chdir() 2020-02-20 18:46:35 +01:00
Daniel Eklöf
b5efe984bb
slave: prefix argv[0] with a '-' when spawning a login-shell 2020-02-20 18:36:09 +01:00
Daniel Eklöf
39146fac5c
term: term_init: add 'cwd' argument
This is used when spawning the slave, to set its current working
directory just before we exec() the client.

In a regular foot instance, we set the cwd from getcwd().

In a foot server instance, each connecting client sends its cwd to the
server, and we use that.
2019-12-21 19:57:28 +01:00
Daniel Eklöf
57de9feaa5
term: term_spawn_new(): new function, spawns a new foot/footclient process
Bind ctrl+shift+return to it
2019-12-21 15:27:17 +01:00
Daniel Eklöf
61dfa1365e
slave: restore signals before calling exec() 2019-11-03 13:24:15 +01:00
Daniel Eklöf
d3e4ba6c94
slave: remove unneeded define 2019-11-03 13:02:16 +01:00
Daniel Eklöf
8cf981ca12
slave: turn on FD_CLOEXEC after slave has been spawned
This ensures that our ptmx FD isn't carried over to other terminals
spawned later.
2019-11-03 01:14:02 +01:00
Daniel Eklöf
69d62d3cd2
slave: set TERM environment variable in slave process 2019-11-01 21:01:15 +01:00
Daniel Eklöf
54039c1fb4
slave: log child's errno, not parents 2019-10-30 20:21:19 +01:00
Daniel Eklöf
98ccd01c1b
slave: fix debug logging (no 'term' variable) 2019-10-30 20:20:56 +01:00
Daniel Eklöf
18921f7f45
term: move client startup to a new function, slave_spawn() 2019-10-30 18:05:03 +01:00
Daniel Eklöf
ce5f5e4d51
slave: rename slave_spawn() -> slave_exec() 2019-10-30 17:30:58 +01:00
Daniel Eklöf
c11cc2be57
main: allow user to override shell on the command line 2019-07-17 09:55:36 +02:00
Daniel Eklöf
2046dc0fbd
slave: break out command line tokenizer 2019-07-17 09:46:45 +02:00
Daniel Eklöf
aa87be43ba
slave: report exec() failure back to main process 2019-07-17 09:39:12 +02:00
Daniel Eklöf
153894eb73
slave: exec shell from conf 2019-07-17 09:30:39 +02:00
Daniel Eklöf
1373d18dbc
logging: disable debug logging by default 2019-07-03 20:21:03 +02:00
Daniel Eklöf
34fb86724f
slave: remove initial debug code 2019-06-29 20:49:35 +02:00
Daniel Eklöf
2a4c08b941
wip: vt parsing: initial csi/osc dispatching 2019-06-15 22:22:44 +02:00
Daniel Eklöf
9f9949aeec
Initial handling of multi byte characters
Use mblen() to calculate the byte count for each character.
2019-06-13 21:23:52 +02:00
Daniel Eklöf
46e3c9d4d4
Render cursor 2019-06-13 20:40:03 +02:00
Daniel Eklöf
71703e7dc6
Use frame callback to rate-limit surface updates 2019-06-13 17:14:14 +02:00
Daniel Eklöf
9ccc8433c3
initial grid implementation
This allows us to render *something*, even though it's inefficient,
stupid and far far away from the real thing.
2019-06-13 16:24:35 +02:00
Daniel Eklöf
acda4d2d31
Set up pseudo terminal and fork slave 2019-06-13 15:19:10 +02:00