fixed a bug on mac in get_foreground_pid()