The San Francisco 49ers have signed free agent quarterback David Carr to a two-year deal and agreed to terms with Detroit on a trade that would send backup quarterback Shaun Hill to the Lions for a 2011 draft pick.