You tell people you're sorry for their loss, generally. Everyone deals differently, though. Some people want comfort, other people want to be left alone, some people want to mourn through silence and others want to celebrate the lives that are left. It's difficult to really say what's a right way.
I mean, as long as you're not laughing about death or something you're reacting pretty much ok.