in reply to Re^2: fork - alarm - output
in thread fork - alarm - output

You did not "look" to do the same thing, which is why the posted solutions didn't work. You don't want to just kill the child (sh), you want to kill its grandchildren too (sleep). As you've discovered, one does that by creating a new process group for the children (setgrp), and killing the process group (negative signal).