While I am here, call forkshell() explicitly FORK_FOO flags instead of depending in FORK_FG == 0 and FORK_BG == 1.