After following a few hints from the other answers, I came up with this messy script:
firefox -no-remote -p c-portal &
ffpid=`ps aux | grep firefox | sed '2q;d' | tr -s ' ' | cut -d ' ' -f 2`
echo "firefox pid: $ffpid"
I also needed to go into about:config and change
browser.sessionstore.resume_from_crash to false.
Explanation of each command: ps aux gets the full list of processes on the system, grep finds all the ones containing firefox, sed gets the second line (which appears to always be the latest instance of firefox), tr removes the extra spaces, cut gets the second column (-d means delimiter, which is a space).
After that string-processing mess, there's a debug thing that prints out the PID of firefox, sleep for 4 seconds, so it can log in, then it kills firefox. The about:config setting prevents it from trying to restore the session.