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