Go to the documentation of this file.
38 #include <QCoreApplication>
46 #if CONFIG_CYGWIN || defined(_WIN32)
59 #if CONFIG_CYGWIN || defined(_WIN32)
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);
303 int posix_signal = SIGTRAP;
324 if (SIGTRAP == posix_signal)
326 LOG(VB_SYSTEM, LOG_ERR,
327 QString(
"Programmer error: Unknown signal %1").arg(sig));
339 LOG(VB_SYSTEM, LOG_DEBUG, QString(
"status: %1").arg(
m_status));
351 LOG(VB_SYSTEM, LOG_DEBUG,
"Adding background flag");
417 return m_stdbuff[0].write(ba.constData());
482 if (out.contains(
"\""))
483 out = out.replace(
"\"",
"\\\"");
485 if (out.contains(
"\'"))
486 out = out.replace(
"\'",
"\\\'");
488 if (out.contains(
" "))
507 uint result = ms->Wait(0s);
508 if (!ms->GetSetting(
"RunInBackground"))
515 std::chrono::seconds Timeout)
520 uint result = ms->Wait(0s);
521 if (!ms->GetSetting(
"RunInBackground"))
@ kMSStdErr
allow access to stderr
QByteArray & ReadAllErr()
static Type kLockInputDevicesEventType
#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 Type kPushDisableDrawingEventType
MythSystemLegacyPrivate(const QString &debugName)
static Type kPopDisableDrawingEventType
virtual void Term(bool force=false)=0
QObject * GetGUIObject(void)
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
#define GENERIC_EXIT_INVALID_CMDLINE
Command line parse error.
uint myth_system(const QString &command, uint flags, std::chrono::seconds timeout)
virtual bool ParseShell(const QString &cmd, QString &abscmd, QStringList &args)=0
#define GENERIC_EXIT_NO_HANDLER
No MythSystemLegacy Handler.
void SetCommand(const QString &command, uint flags)
Resets an existing MythSystemLegacy object to a new command.
void Signal(MythSignal sig)
~MythSystemLegacy(void) override
static QString ShellEscape(const QString &in)
bool GetSetting(const char *setting)
uint Wait(std::chrono::seconds timeout=0s)
virtual void Signal(int sig)=0
#define GENERIC_EXIT_CMD_NOT_FOUND
Command not found.
void SetDirectory(const QString &directory)
static Type kDisableUDPListenerEventType
@ 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
@ kMSAutoCleanup
automatically delete if backgrounded
@ kMSRunBackground
run child in the background
MythSystemLegacy(QObject *parent=nullptr)
@ kMSDisableUDPListener
disable MythMessage UDP listener for the duration of application.
static Type kUnlockInputDevicesEventType
@ 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
#define GENERIC_EXIT_START
MythSystemLegacy process starting.
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.
#define GENERIC_EXIT_RUNNING
Process is running.
@ kMSDontDisableDrawing
avoid disabling UI drawing
@ kMSStdIn
allow access to stdin
@ kMSStdOut
allow access to stdout
QByteArray Read(int size)
MythSystemLegacyPrivate * d
virtual void Manage(void)=0
General purpose reference counter.
void initializePrivate(void)
static Type kEnableUDPListenerEventType