I found that even though I know perfectly well to terminate mendel_talk with ^D, my fingers don't always remember, and then I forget why mendel_cmd isn't working and waste time.
So I fixed it to check for "cat" processes started from this terminal before and after, and if there aren't any before and are after, kill it! (sorry, hard sentance to parse, code is easier)
This way it doesn't matter if I forget and hit ^C instead, unless I already have a job running with a "cat" process in it. Which is unlikely, but at least this code won't screw up already running processes.
In theory, I suppose that I could make it check, store the list, and compare. But that's way to much effort for a corner case. I mean, I almost didn't even bother to check for previously running "cat" processes.
I found that even though I know perfectly well to terminate mendel_talk with ^D, my fingers don't always remember, and then I forget why mendel_cmd isn't working and waste time.
So I fixed it to check for "cat" processes started from this terminal before and after, and if there aren't any before and are after, kill it! (sorry, hard sentance to parse, code is easier)
This way it doesn't matter if I forget and hit ^C instead, unless I already have a job running with a "cat" process in it. Which is unlikely, but at least this code won't screw up already running processes.
In theory, I suppose that I could make it check, store the list, and compare. But that's way to much effort for a corner case. I mean, I almost didn't even bother to check for previously running "cat" processes.
Also added a few comments.