Commit Graph

9906 Commits

Author SHA1 Message Date
ridiculousfish
780b53ba73 Convert event_type_t to an enum class 2019-02-23 13:17:28 -08:00
ridiculousfish
1b8ddacfed Reimplement signal handling event machinery
Prior to this fix, fish had a signal_list_t that accumulated signals.
Signals were added to an array of integers, with an overflow flag.
The event machinery would attempt to atomically "swap in" the other list.

After this fix, there is a single list of pending signal events, as an array
of atomic booleans. The signal handler sets the boolean corresponding to its
signal.
2019-02-23 13:03:33 -08:00
ridiculousfish
003998c921 Event blocks just block all events
In a galaxy far, far away, event_blockage_t was intended to block only cetain
events. But it always just blocked everything. Eliminate the event block
mask.
2019-02-23 13:02:07 -08:00
ridiculousfish
f015f930f1 Enhance the signal test 2019-02-23 12:41:01 -08:00
ridiculousfish
0f30f05e16 Remove EVENT_ANY_SIGNAL
This appeared to have been intended to allow functions to handle all signals,
but this has not been exposed and it doesn't seem useful.
2019-02-23 12:19:59 -08:00
ridiculousfish
6bddf2c83b Add basic signal test 2019-02-23 11:57:19 -08:00
ridiculousfish
da04f757f9 Minor cleanup to process_clean_after_marking 2019-02-22 22:50:52 -08:00
Fabian Homborg
f451499aa6 completions/valgrind: Fix option typo
Fixes #5688.

[ci skip]
2019-02-22 20:03:53 +01:00
Fabian Homborg
c6ec423513 completions/systemctl: Harden version comparison
Arch changed the version string to include the package rel, so it
looks like

    systemd 241 (241.7-2-arch)

which would break our simple `string replace` and `test`.

Fixes #5689.

[ci skip]
2019-02-22 20:00:08 +01:00
ridiculousfish
38d86acbc3 Fix s_var_dispatch_table initialization
It has to be declared after the variables it uses.
2019-02-20 16:33:54 -08:00
George Christou
de0b64409c Teach autosuggestions to respect forward-bigword
Closes #5336
2019-02-20 16:06:38 -08:00
ridiculousfish
75e83cac29 pwd short_options to be const 2019-02-20 16:06:05 -08:00
ridiculousfish
13b2ff336d Make var_dispatch_table const 2019-02-20 16:06:05 -08:00
Max Nordlund
44ad92ef50 Fix typo 2019-02-20 16:00:59 -08:00
ridiculousfish
e234856190 Define _REENTRANT
This enables thread-safe errno on Solaris and its descendants.

Fixes #5611
2019-02-20 13:58:36 -08:00
Fabian Homborg
50f6fa048e completions/sudo: Quote ?
This was treated as a glob where it was still enabled, most likely removing the "-E" option from argparse,
which caused `sudo -E` to not be parsed correctly, breaking completion.

(There was no error because the glob was used with `set`)

Fixes #5675.

[ci skip]
2019-02-20 22:30:29 +01:00
ridiculousfish
177adb6837 Revert "Define _POSIX_C_SOURCE=200809L"
This reverts commit 334eec94f8.

This broke the Mac build
2019-02-20 13:28:46 -08:00
ridiculousfish
334eec94f8 Define _POSIX_C_SOURCE=200809L
This enables thread-safe errno on Solaris and its descendants.

Fixes #5611
2019-02-20 12:58:59 -08:00
Aaron Gyes
11a1403219 Remove extra semicolons 2019-02-19 16:50:58 -08:00
David Adam
28f57aa8ab Bump version for 3.0.2 2019-02-19 21:39:17 +08:00
David Adam
d44308388f cmake: use the check state stack for __nl_msg_cat_cntr checks 2019-02-19 21:35:30 +08:00
David Adam
6e24061468 CHANGELOG: updates for 3.0.2 2019-02-19 21:30:49 +08:00
Fabian Homborg
59955391ad completions/yarn: Allow running scripts as subcommand
Fixes #5674.

[ci skip]
2019-02-19 14:24:02 +01:00
Aaron Gyes
6aa2f29901 Don't increase the width for variation selector 15.
See discussion in #5668 and #5583
2019-02-19 04:27:17 -08:00
Fabian Homborg
8a93c7d0ea abbr: Add "-q"/"--query" option
[ci skip]
2019-02-19 11:02:58 +01:00
Fabian Homborg
38f37b7abc commandline: Remove stray "w" short option
Fun fact: `commandline -w` hits an assert and crashes.
2019-02-19 11:02:58 +01:00
Aaron Gyes
3fe9353599
style guide: allow multi-line comments (#5670)
Closes #5670.
2019-02-19 01:54:45 -08:00
Aaron Gyes
6fa8b028fc fish_tests.cpp: fixup: I didn't notice the comma here. 2019-02-18 23:19:57 -08:00
Aaron Gyes
c2bc0c67f2 Don't use printf("%d") just to convert an int to a string.
std::to_string, std::to_wstring are more appropriate
2019-02-18 23:15:54 -08:00
ridiculousfish
5c994b0d47 Only inherit a PWD if it resolves to "."
Fixes #5647
2019-02-18 14:32:15 -08:00
ridiculousfish
59cb2d02a8 Only inherit a PWD if it resolves to "."
Fixes #5647
2019-02-18 13:20:40 -08:00
Jonathan Revah
8e41e3337c small typo in the tutorial. stderr is redirected using 2> rather than >2 2019-02-18 22:08:58 +01:00
Fabian Homborg
1c3fe7dc66 tests/expansion: Use rm instead of unlink
unlink(1) is apparently not always installed everywhere.

Since there is no real difference, just use rm.
2019-02-18 15:39:58 +01:00
Fabian Homborg
18a9141fb4 Remove comment in yaml
I should actually look up the syntax one of these days.
2019-02-18 15:25:57 +01:00
Fabian Homborg
7eb6bee793 Add NetBSD on sr.ht 2019-02-18 15:22:47 +01:00
Fabian Homborg
c242469e8b cmake: Keep rpath on NetBSD
Otherwise it'd fail to find pcre2 in the invocation tests.
2019-02-18 15:22:30 +01:00
Fabian Homborg
11009de431 Revert "Explicitly close input fd to fish_title"
This reverts commit b247c8d9ad.

It breaks the title entirely.

[ci skip]
2019-02-18 15:04:01 +01:00
Fabian Homborg
7958e1d5c4 fish_tests: s/rand()/random()/g
As it turns out, NetBSD's rand(3) is awful - it's possible that in any
given run it'll only return odd numbers, which means

    while (rand() % 10)

will never stop.

Since random(3) is also standardized and works, let's use that!
2019-02-18 14:46:11 +01:00
ridiculousfish
13ab9e541e Implement new event mechanism and migrate builtin and block output
This commit merges support for a new event publishing mechanism
"topic_monitor" that allow for waiting on multiple event types. It then
replaces waitpid() logic inside `process_mark_finished_children` with new
and simpler logic built around this mechanims. Lastly it migrates the
builtin and function output from processes to background threads.
2019-02-17 21:42:18 -08:00
ridiculousfish
0b3eca1743 Cleanup handle_builtin_output
Now that we use an internal process to perform builtin output, simplify the
logic around how it is performed. In particular we no longer have to be
careful about async-safe functions since we do not fork.

Also fix a bunch of comments that no longer apply.
2019-02-17 14:17:44 -08:00
ridiculousfish
4a2fd443b2 Use internal processes to write builtin output
This uses the new internal process mechanism to write output for builtins.
After this the only reason fish ever forks is to execute external processes.
2019-02-17 13:08:00 -08:00
ridiculousfish
ada8ea954e Use "internal" processes to write buffered output
This introduces "internal processes" which are backed by a pthread instead
of a normal process. Internal processes are reaped using the topic
machinery, plugging in neatly alongside the sigchld topic; this means that
process_mark_finished_children() can wait for internal and external
processes simultaneously.

Initially internal processes replace the forked process that fish uses to
write out the output of blocks and functions.
2019-02-17 13:05:20 -08:00
ridiculousfish
061f8f49c6 Add dup2_list_t::fd_for_target_fd
This adds an "in-process" interpretation of dup2s, allowing for fish to
output directly to the correct file descriptor without having to perform
an in-kernel dup2 sequence.
2019-02-17 13:01:59 -08:00
ridiculousfish
ebe2dc2766 Processes to record topic generations before execution
The sigchld generation expresses the idea that, if we receive a sigchld
signal, the generation will be different than when we last recorded it. A
process cannot exit before it has launched, so check the generation count
before process launch. This is an optimization that reduces failing
waitpid calls.
2019-02-17 13:01:59 -08:00
ridiculousfish
a95bc849c5 Rewrite process_mark_finished_children using topics
This is a big change to how process reaping works, reimplenting it using
topics. The idea is to simplify the logic in
process_mark_finished_children around blocking, and also prepare for
"internal processes" which do not correspond to real processes.

Before this change, fish would use waitpid() to wait for a process group,
OR would individually poll processes if the process group leader was
unreapable.

After this change, fish no longer ever calls blocking waitpid(). Instead
fish uses the topic mechanism. For each reapable process, fish checks if
it has received a SIGCHLD since last poll; if not it waits until the next
SIGCHLD, and then polls them all.
2019-02-17 13:01:59 -08:00
ridiculousfish
a4dc04a28e Add sighupint topic
This corresponds to SIGHUP and SIGINT. This will be used to break out of
process_mark_finished_children().
2019-02-17 13:01:59 -08:00
ridiculousfish
fc9d238642 Introduce topic monitoring
topic_monitor allows for querying changes posted to one or more topics,
initially sigchld. This will eventually replace the waitpid logic in
process_mark_finished_children().

Comment from the new header:

Topic monitoring support. Topics are conceptually "a thing that can
happen." For example, delivery of a SIGINT, a child process exits, etc. It
is possible to post to a topic, which means that that thing happened.

Associated with each topic is a current generation, which is a 64 bit
value. When you query a topic, you get back a generation. If on the next
query the generation has increased, then it indicates someone posted to
the topic.

For example, if you are monitoring a child process, you can query the
sigchld topic. If it has increased since your last query, it is possible
that your child process has exited.

Topic postings may be coalesced. That is there may be two posts to a given
topic, yet the generation only increases by 1. The only guarantee is that
after a topic post, the current generation value is larger than any value
previously queried.

Tying this all together is the topic_monitor_t. This provides the current
topic generations, and also provides the ability to perform a blocking
wait for any topic to change in a particular topic set. This is the real
power of topics: you can wait for a sigchld signal OR a thread exit.
2019-02-17 13:01:59 -08:00
ridiculousfish
ccc45235b0 Introduce enum_array_t
Allows for indexing an array via an enum class.
2019-02-17 13:01:59 -08:00
ridiculousfish
78ed659151 Fancify enum_set and introduce enum_iter_t
Allow iterating over the values of an enum class.
2019-02-17 13:01:59 -08:00
Collin Styles
8a0be93e50 Add completions for "git remote get-url" 2019-02-17 16:30:00 +01:00