0

I'm using a Pi to command an home-made robot. For that I run several python scripts (and one programme in C++), they consume many CPU. I want to let the robot working for several days in a row. But after few hours it seems the Pi closes all the terminal.

At first I thought the Pi rebooted during the night. But once it did it during the day, and I could check that my SSH connection was not closed.

Is there a kind of protection in the Pi that closes all the process if I requiring to much CPU? And is there a way to check what happened, like a log file? I already check last -x for any savage reboot.

If you need any further information, please let me know. I don't know what could be useful. Thanks in advance.

NB: the C++ program takes itself 100% of one CPU.

UPDATE with info from comment:
I'm using RPi 4 with 8 GB of RAM. I'm using an homemade power delivery that supplies 5 V - 3 A. I never got problems with it, the Pi doesn't shutdown and never display the lightning. Moreover in last -x I couldn't find any power shutdown.

1
  • What Raspberry Pi version do you use? What power supply do you use?
    – Ingo
    Jan 29, 2021 at 17:37

2 Answers 2

3

Is there a kind of protection in the Pi that closes all the process if I requiring to much CPU?

For CPU, no. However, there is a mechanism which kills processes if the system runs out of memory. You can see those with:

grep -i 'killed process' /var/log/messages

If you find a process which is getting killed, check it for memory leaks.

3
  • The command returned nothing, so I guess no killed happened. But I'll try it again just after the problem happens. Feb 1, 2021 at 5:52
  • Does this process kills everything in case of memory leakage? I mean I have one Python script and one C++ program that are running together. If one is fulling the memory, does the Pi stop everything, or just the incriminated program? Feb 1, 2021 at 6:03
  • @DarkPatate Out-Of-Memory handler certainly doesn't kill 'everything'. It normally kills one process at a time. However, your scripts may interact with each other in a way that makes them fail together. E.g. if you run find / | grep and you kill find, grep will also be killed when it tries to get new data from find. Feb 1, 2021 at 8:08
0

You can take a look at the logfiles in /var/log and look at the output of the dmesg command to see if there is any hints. The Pi (or any other computer running Linux) should not terminate a process if it is using too much cpu, just get slower. But running out of memory could cause that. Another option is, that there is a bug in the programs that terminates them.

1
  • I should check, the script, indeed, a bug could be a problem. Maybe I should add a system("PAUSE") at the end of the script, to see if it is the problem. I hope it's not RAM leakage, it'd would be more problematic to correct ^^ Feb 1, 2021 at 5:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.