[core] Fix unsound noforklast optimization - when pipefail is on