38#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
39#include <QtSystemDetection>
41#include <QCoreApplication>
72 setObjectName(
"MythSystemLegacy()");
81 setObjectName(QString(
"MythSystemLegacy(%1)").arg(command));
102 LOG(VB_GENERAL, LOG_ERR,
103 QString(
"MythSystemLegacy(%1) command not understood")
122 const QStringList &
args,
136 const QStringList &
args,
uint flags)
162 if (!
GetSetting(
"UseShell") && (access(command.toUtf8().constData(), X_OK)) != 0)
164 LOG(VB_GENERAL, LOG_ERR,
165 QString(
"MythSystemLegacy(%1) command not executable, ")
166 .arg(command) +
ENO);
258 while (SystemClock::now() < tt)
267 qApp->processEvents();
274 auto msec = duration_cast<std::chrono::milliseconds>(
timeout);
332 LOG(VB_SYSTEM, LOG_ERR,
333 QString(
"Programmer error: Unknown signal %1").arg(sig));
345 LOG(VB_SYSTEM, LOG_DEBUG, QString(
"status: %1").arg(
m_status));
357 LOG(VB_SYSTEM, LOG_DEBUG,
"Adding background flag");
423 return m_stdbuff[0].write(ba.constData());
488 if (out.contains(
"\""))
489 out = out.replace(
"\"",
"\\\"");
491 if (out.contains(
"\'"))
492 out = out.replace(
"\'",
"\\\'");
494 if (out.contains(
" "))
513 uint result = ms->Wait(0s);
514 if (!ms->GetSetting(
"RunInBackground"))
521 std::chrono::seconds Timeout)
526 uint result = ms->Wait(0s);
527 if (!ms->GetSetting(
"RunInBackground"))
QObject * GetGUIObject(void)
static const Type kPushDisableDrawingEventType
static const Type kDisableUDPListenerEventType
static const Type kUnlockInputDevicesEventType
static const Type kPopDisableDrawingEventType
static const Type kEnableUDPListenerEventType
static const Type kLockInputDevicesEventType
virtual void Fork(std::chrono::seconds timeout)=0
MythSystemLegacyPrivate(const QString &debugName)
virtual void Signal(int sig)=0
virtual void Term(bool force=false)=0
virtual bool ParseShell(const QString &cmd, QString &abscmd, QStringList &args)=0
virtual void Manage(void)=0
void SetCommand(const QString &command, uint flags)
Resets an existing MythSystemLegacy object to a new command.
uint Wait(std::chrono::seconds timeout=0s)
QByteArray ReadErr(int size)
MythSystemLegacyPrivate * d
~MythSystemLegacy(void) override
QByteArray & ReadAllErr()
static QString ShellEscape(const QString &in)
MythSystemLegacy(QObject *parent=nullptr)
uint GetStatus(void) const
void Term(bool force=false)
void SetDirectory(const QString &directory)
int Write(const QByteArray &ba)
This writes to the standard input of the program being run.
void Run(std::chrono::seconds timeout=0s)
Runs a command inside the /bin/sh shell. Returns immediately.
void ProcessFlags(uint flags)
QByteArray Read(int size)
std::array< QBuffer, 3 > m_stdbuff
void Signal(MythSignal sig)
bool GetSetting(const char *setting)
void initializePrivate(void)
General purpose reference counter.
virtual int DecrRef(void)
Decrements reference count and deletes on 0.
@ GENERIC_EXIT_START
MythSystemLegacy process starting.
@ GENERIC_EXIT_CMD_NOT_FOUND
Command not found.
@ GENERIC_EXIT_NO_HANDLER
No MythSystemLegacy Handler.
@ GENERIC_EXIT_RUNNING
Process is running.
@ GENERIC_EXIT_INVALID_CMDLINE
Command line parse error.
bool logPropagateQuiet(void)
Check if we are propagating a "--quiet".
QStringList logPropagateArgList
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
#define ENO
This can be appended to the LOG args with "+".
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
@ kMSDontBlockInputDevs
avoid blocking LIRC & Joystick Menu
@ kMSProcessEvents
process events while waiting
@ kMSStdIn
allow access to stdin
@ kMSStdErr
allow access to stderr
@ kMSPropagateLogs
add arguments for MythTV log propagation
@ kMSStdOut
allow access to stdout
@ kMSLowExitVal
allow exit values 0-127 only
@ kMSRunShell
run process through shell
@ kMSDisableUDPListener
disable MythMessage UDP listener for the duration of application.
@ kMSAnonLog
anonymize the logs
@ kMSRunBackground
run child in the background
@ kMSDontDisableDrawing
avoid disabling UI drawing
@ kMSAutoCleanup
automatically delete if backgrounded
uint myth_system(const QString &command, uint flags, std::chrono::seconds timeout)