In the code below, both the readeble and writable event scripts are executed, but bgerror never runs because the queue is dominated by the fileevent events.

----

#! tclsh

proc handler {arg} {
    return -code error "an error!"
}

lassign [chan pipe] pipeout pipein
set stdout [open |[list echo hello]]
fileevent $pipein writable {apply {{} {}}}
fileevent $stdout readable [list handler $stdout]

vwait exit