duino-coin icon indicating copy to clipboard operation
duino-coin copied to clipboard

PC_Miner not killing processes on exit

Open StickyDigit opened this issue 4 years ago • 1 comments

The PC_Miner (v3.0), when closed with ctrl-C, does not kill off the current threads, rather it returns the command prompt, and seems to let the started tasks run to conclusion (I guess, as they are at the top of the list in 'top' for a while).

Tasks continue to warm the CPU despite the miner cheerfully leaving with "SIGINT detected - Exiting gracefully. See you soon!".

pls. pardon the hacky, unsafe bash-ing that follows.

This is what ps awux | sed -n "1p;/PC_Miner/p" | grep -v sed shows a second or two after ctrl-c has got me a "See you soon!" and the shell prompt has returned.

USER         PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
user       11582  0.1  1.3 409600 26872 pts/1    Sl   20:42   0:00 python3 PC_Miner.py
user       11587  0.1  1.3 409600 26960 pts/1    Sl   20:42   0:00 python3 PC_Miner.py
user       11593  0.0  1.3 188404 26964 pts/1    Sl   20:42   0:00 python3 PC_Miner.py
user       11600  0.1  1.3 409600 26924 pts/1    Sl   20:42   0:00 python3 PC_Miner.py
user       11629 83.6  1.3  47864 27204 pts/1    R    20:42   0:19 python3 PC_Miner.py
user       11634 85.8  1.3  47864 27332 pts/1    R    20:42   0:19 python3 PC_Miner.py
user       11639 81.6  1.3  47864 27332 pts/1    R    20:42   0:18 python3 PC_Miner.py
user       11644 83.2  1.3  47864 27332 pts/1    R    20:42   0:19 python3 PC_Miner.py

Once the tasks have stopped eating CPU, maybe a minute later, the ones that were not working hard seem to linger until killed.

ps awux | sed -n "1p;/PC_Miner/p" | grep -v sed
USER         PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
user       11582  0.0  1.3 409600 26968 pts/1    Sl   20:42   0:00 python3 PC_Miner.py
user       11587  0.0  1.3 409600 27048 pts/1    Sl   20:42   0:00 python3 PC_Miner.py
user       11593  0.0  1.3 188404 26964 pts/1    Sl   20:42   0:00 python3 PC_Miner.py
user       11600  0.0  1.3 409600 27000 pts/1    Sl   20:42   0:00 python3 PC_Miner.py

Here's what I saw earlier after running the python and precompiled versions a few times. Some of these processes have been lingering a while.

user@pc:~/duino-coin-3.0$ ps awux | sed -n "1p;/PC_Miner/p" | grep -v sed
USER         PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
user        3863  0.0  0.0 410444   696 pts/1    Sl   18:00   0:01 python3 PC_Miner.py
user        3868  0.0  0.0 410444   716 pts/1    Sl   18:00   0:01 python3 PC_Miner.py
user        3874  0.0  0.0 189248   756 pts/1    Sl   18:00   0:01 python3 PC_Miner.py
user        3881  0.0  0.0 410444   712 pts/1    Sl   18:00   0:01 python3 PC_Miner.py
user        4070  0.0  0.0 409600   676 pts/1    Sl   18:12   0:01 python3 PC_Miner.py
user        4075  0.0  0.0 409600   680 pts/1    Sl   18:12   0:01 python3 PC_Miner.py
user        4081  0.0  0.0 262136   692 pts/1    Sl   18:12   0:01 python3 PC_Miner.py
user        4088  0.0  0.0 409600   676 pts/1    Sl   18:12   0:01 python3 PC_Miner.py
user        4282  0.0  0.0 188404   564 pts/1    Sl   18:17   0:01 python3 PC_Miner.py
user        4287  0.0  0.0 196600   628 pts/1    Sl   18:17   0:01 python3 PC_Miner.py
user        4293  0.0  0.0 196600   616 pts/1    Sl   18:17   0:01 python3 PC_Miner.py
user        4300  0.0  0.0 188404   580 pts/1    Sl   18:17   0:01 python3 PC_Miner.py
user       11022  0.0  1.3 414244 26976 pts/1    Sl   20:13   0:00 ./PC_Miner
user       11027  0.0  1.3 414244 27060 pts/1    Sl   20:13   0:00 ./PC_Miner
user       11033  0.0  1.3 193048 26972 pts/1    Sl   20:13   0:00 ./PC_Miner
user       11040  0.0  1.3 414244 27068 pts/1    Sl   20:13   0:00 ./PC_Miner

Clearly some leftovers :-(

When I clean these up with... kill $(ps awux | grep PC_Miner | grep -v grep | awk '{print $2}') ... they go without a fight. No "kill -9" brutality required.

This is on LinuxMint 20.3. Python 3.8.10 (when running with "python3 PC_Miner.py"). It's happening with the pre-compiled version too.

I would hope that the miner ought to not return the prompt with WTE "all done" until it has actually cleaned up after itself.

(edited fumbled quotes in bash stuff)

StickyDigit avatar Jan 17 '22 20:01 StickyDigit

Hi, ty for the notice (And part of the fix). you can see the fix on this Commit.

I`ll close this issue.

LDarki avatar Jan 29 '22 23:01 LDarki