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.
This commit is contained in:
ridiculousfish 2019-02-20 21:41:35 -08:00
parent f015f930f1
commit 003998c921
4 changed files with 21 additions and 14 deletions

View file

@ -102,7 +102,6 @@ int builtin_block(parser_t &parser, io_streams_t &streams, wchar_t **argv) {
block_t *block = parser.block_at_index(block_idx);
event_blockage_t eb = {};
eb.typemask = (1 << EVENT_ANY);
switch (opts.scope) {
case LOCAL: {

View file

@ -20,24 +20,14 @@
class io_chain_t;
/// event_blockage_t represents a block on events of the specified type.
/// event_blockage_t represents a block on events.
struct event_blockage_t {
/// The types of events to block. This is interpreted as a bitset whete the value is 1 for every
/// bit corresponding to a blocked event type. For example, if EVENT_VARIABLE type events should
/// be blocked, (type & 1<<EVENT_BLOCKED) should be set.
///
/// Note that EVENT_ANY can be used to specify any event.
unsigned int typemask;
};
typedef std::list<event_blockage_t> event_blockage_list_t;
inline bool event_block_list_blocks_type(const event_blockage_list_t &ebls, int type) {
for (event_blockage_list_t::const_iterator iter = ebls.begin(); iter != ebls.end(); ++iter) {
if (iter->typemask & (1 << EVENT_ANY)) return true;
if (iter->typemask & (1 << type)) return true;
}
return false;
return !ebls.empty();
}
/// Types of blocks.

View file

@ -2,7 +2,6 @@ function alarm --on-signal ALRM
echo ALRM received
end
kill -s ALRM $fish_pid
function anychild --on-process-exit 0
@ -10,6 +9,17 @@ function anychild --on-process-exit 0
echo $argv[1] $argv[3]
end
echo "command false:"
command false
echo "command true:"
command true
echo "command false | true:"
command false | command true
function test_blocks
block -l
command echo "This is the process whose exit event shuld be blocked"
echo "This should come before the event handler"
end
test_blocks
echo "Now event handler should have run"

View file

@ -1,9 +1,17 @@
ALRM received
command false:
PROCESS_EXIT 1
JOB_EXIT 0
command true:
PROCESS_EXIT 0
JOB_EXIT 0
command false | true:
PROCESS_EXIT 1
PROCESS_EXIT 0
JOB_EXIT 0
This is the process whose exit event shuld be blocked
This should come before the event handler
PROCESS_EXIT 0
JOB_EXIT 0
Now event handler should have run
PROCESS_EXIT 0