38#include <QCoreApplication>
69 setObjectName(
"MythSystemLegacy()");
78 setObjectName(QString(
"MythSystemLegacy(%1)").arg(command));
99 LOG(VB_GENERAL, LOG_ERR,
100 QString(
"MythSystemLegacy(%1) command not understood")
119 const QStringList &
args,
133 const QStringList &
args,
uint flags)
159 if (!
GetSetting(
"UseShell") && (access(command.toUtf8().constData(), X_OK)) != 0)
161 LOG(VB_GENERAL, LOG_ERR,
162 QString(
"MythSystemLegacy(%1) command not executable, ")
163 .arg(command) +
ENO);
255 while (SystemClock::now() < tt)
264 qApp->processEvents();
271 auto msec = duration_cast<std::chrono::milliseconds>(
timeout);
329 LOG(VB_SYSTEM, LOG_ERR,
330 QString(
"Programmer error: Unknown signal %1").arg(sig));
342 LOG(VB_SYSTEM, LOG_DEBUG, QString(
"status: %1").arg(
m_status));
354 LOG(VB_SYSTEM, LOG_DEBUG,
"Adding background flag");
420 return m_stdbuff[0].write(ba.constData());
485 if (out.contains(
"\""))
486 out = out.replace(
"\"",
"\\\"");
488 if (out.contains(
"\'"))
489 out = out.replace(
"\'",
"\\\'");
491 if (out.contains(
" "))
510 uint result = ms->Wait(0s);
511 if (!ms->GetSetting(
"RunInBackground"))
518 std::chrono::seconds Timeout)
523 uint result = ms->Wait(0s);
524 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)