Fix Ctr-C and Ctr-D behavior.

We replace the cmdloop function with a slightly modified version
to achieve standard unix shell behavior on keyboard interupts and EOF.
Merge pull request #314 from colah/Ctr-C-D-fix

Fix Ctr-C and Ctr-D behavior.