Sonde v1.1.0
Embeddable Model Context Protocol server for Qt applications
Loading...
Searching...
No Matches
processes.h File Reference

What sonde needs from the platform to run the application (design 0030): start it in a process group of its own, know whether a pid is still the process it started, and stop it with what it started. More...

#include <QtCore/QProcess>
#include <QtCore/QString>
#include <array>

Go to the source code of this file.

Classes

class  Sonde::Cli::StdHandlesNotInherited
 Makes sonde's own standard input, output and error not inherited by the processes it starts, for as long as it exists: on Windows, QProcess lets a child inherit every inheritable handle, and a child that outlives the command (the application, or a build server) would keep a caller's pipe open. More...

Namespaces

namespace  Sonde
 Embeddable Model Context Protocol server for Qt applications.

Functions

void Sonde::Cli::startInOwnGroup (QProcess &process)
 Prepares process to start the application in a group of its own (a new session on POSIX, a new process group on Windows), so that it keeps running after sonde exits and can be stopped with what it starts.
QString Sonde::Cli::processStartTime (qint64 pid)
 When process pid started, as ps -o lstart= gives it on POSIX (local time, "Tue Dec 1 13:04:05 2026") or as Windows' creation time (a FILETIME, in decimal), or an empty string if it is unknown.
bool Sonde::Cli::processAlive (qint64 pid)
 Whether process pid exists and is ours to signal: not gone, not another user's, and not a zombie.
bool Sonde::Cli::signalGroup (qint64 pid, bool kill)
 Stops the application's process group (POSIX: SIGTERM, or SIGKILL if kill), or ends its process tree (Windows, at once in either case).

Detailed Description

What sonde needs from the platform to run the application (design 0030): start it in a process group of its own, know whether a pid is still the process it started, and stop it with what it started.

Function Documentation

◆ processAlive()

bool Sonde::Cli::processAlive ( qint64 pid)

Whether process pid exists and is ours to signal: not gone, not another user's, and not a zombie.

A process that is exiting is alive until it is a zombie with no thread left but its main one (on Linux the main thread is a zombie as soon as it has exited, while the others end): until then it may still hold its sockets.

◆ processStartTime()

QString Sonde::Cli::processStartTime ( qint64 pid)

When process pid started, as ps -o lstart= gives it on POSIX (local time, "Tue Dec 1 13:04:05 2026") or as Windows' creation time (a FILETIME, in decimal), or an empty string if it is unknown.

The same text the Python sonde recorded, so either reads the other's pid file.

◆ signalGroup()

bool Sonde::Cli::signalGroup ( qint64 pid,
bool kill )

Stops the application's process group (POSIX: SIGTERM, or SIGKILL if kill), or ends its process tree (Windows, at once in either case).

Returns
Whether there was something to signal.