fix broken STDIN in child, refs rt-47268
make select restartable, refs rt-41482
fix possible uninitialized value, refs rt-36970