Ticket #3910: 05-3910-mythshutdown-util-isRunning.2.patch

File 05-3910-mythshutdown-util-isRunning.2.patch, 2.1 KB (added by Matthew Wire <devel@…>, 18 years ago)

Updated for trunk

  • mythtv/programs/mythshutdown/main.cpp

     
    1717#include "tv.h"
    1818#include "remoteutil.h"
    1919#include "compat.h"
     20#include "util.h"
    2021
    2122void setGlobalSetting(const QString &key, const QString &value)
    2223{
     
    163164    return 0;
    164165}
    165166
    166 bool isRunning(QString program)
    167 {
    168     QString sCommand = QString("ret=`ps cax | grep -c %1`; exit $ret")
    169         .arg(program);
    170     QByteArray aCommand = sCommand.toAscii();
    171     int res = system(aCommand.constData());
    172     if (WIFEXITED(res))
    173         res = WEXITSTATUS(res);
    174 
    175     return res;
    176 }
    177 
    178167QDateTime getDailyWakeupTime(QString sPeriod)
    179168{
    180169    QString sTime = getGlobalSetting(sPeriod, "00:00");
  • mythtv/libs/libmyth/util.h

     
    5050MPUBLIC bool getUptime(time_t &uptime);
    5151MPUBLIC bool getMemStats(int &totalMB, int &freeMB, int &totalVM, int &freeVM);
    5252
     53MPUBLIC bool isRunning(QString program);
     54
    5355MPUBLIC void myth_eject(void);
    5456
    5557MPUBLIC bool hasUtf8(const char *str);
  • mythtv/libs/libmyth/util.cpp

     
    786786    return true;
    787787}
    788788
     789/** \fn isRunning(QString program)
     790 *  \brief Returns boolean true/false depending on whether program is running.
     791 *
     792 * Executes ps and grep to detect whether a program exists as a process.
     793 */
     794bool isRunning(QString program)
     795{
     796    QString sCommand = QString("ret=`ps cax | grep -c %1`; exit $ret")
     797        .arg(program);
     798    QByteArray aCommand = sCommand.toAscii();
     799    int res = system(aCommand.constData());
     800    if (WIFEXITED(res))
     801        res = WEXITSTATUS(res);
     802
     803    return res;
     804}
     805
    789806/**
    790807 * \brief Eject a disk, unmount a drive, open a tray
    791808 *