How does login get to startx

Looking at login.c, after the fork to change to user level priv, login exec's the user shell from /etc/passwd. In my case, this is bash. At the bottom of my .bash_profile, I have

if [ -z "$DISPLAY" ] && [ -n "$XDG_VTNR" ] && [ "$XDG_VTNR" -eq 1 ]; then
exec startx
fi