Implement foregrounding for Unix and Windows.