Fixed the crashing of `/bin/rsh` and some related bugs