0

I have one C++ program that runs another program in a separate process, which does extensive calculations.

How can I know if this other process crashed because of an "out of memory" error?

I use QProcess and QLocalSocket.

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
Lumar
  • 1
  • Crashed or exited because of OOM? If it exits in such cases then you can return a specific return code to help your parent process know about that case – Asesh Aug 03 '22 at 13:39
  • My process was killed by OOM - Killer, how get I find it out from my cpp code ? – Lumar Aug 03 '22 at 21:44
  • Subscribe your own [`sigaction`]https://stackoverflow.com/a/50150506/4123703) to check with the sender of kill signal. – Louis Go Aug 04 '22 at 07:17
  • Or [check](https://unix.stackexchange.com/a/153586/432225) the oom score of the process. – Louis Go Aug 04 '22 at 07:24
  • @LouisGo Okay, I have pid of the process which call this signal. And how I can that it is OOM Killer? – Lumar Aug 04 '22 at 15:43

1 Answers1

1

You cannot get the reason for the crash of a running process executed by QProcess. You can only be informed that it finished (normally or crashed) or that an error occured during execution.

All that can be handled by processing QProcess signals

  1. void QProcess::errorOccurred(QProcess::ProcessError error)
  2. void QProcess::finished(int exitCode, QProcess::ExitStatus exitStatus = NormalExit)

Please, refer to the official documentation.

Alexey
  • 2,439
  • 1
  • 11
  • 15