Nethack is one of the original "roguelikes," back when that meant a text-console game based on `rogue`. It's an RPG where your character kills monsters, picks up loot, and descends into the dungeon. If you die, that's it -- you can't just load a save; you have to start all over. It's legendarily unforgiving.
In Nethack, most (all?) roles start with a pet, e.g. a puppy or a kitten. In the early game, your pet is often stronger than you; it follows you, fights monsters, etc. It's useful in many ways beyond fighting: it won't walk over a cursed item, it can "fetch" items from stores without angering the proprietor, and so on. Your pet gains experience and levels up (puppy -> dog -> large dog), and after a certain point you're prompted to give your pet a name.
The message "You have a sad feeling for a moment, then it passes" is displayed when your pet dies while out of sight. It's pretty difficult to keep your pet alive all through the endgame, so much like any real-life pet owner, there will come a time where you have to say goodbye, one way or the other.