Get proper PID for local and remote background jobs.