Ticket #3910: libmyth-util_isRunning31082007.diff

File libmyth-util_isRunning31082007.diff, 1.1 KB (added by Matthew Wire <devel@…>, 19 years ago)

isRunning function

  • libs/libmyth/util.cpp

     
    280280    return GENERIC_EXIT_NOT_OK;
    281281}
    282282
     283/** \fn isRunning(QString program)
     284 *  \brief Returns true if program is running.
     285 */
     286bool isRunning(QString program)
     287{
     288    QString sCommand = QString("ret=`ps cax | grep -c %1`; exit $ret").arg(program);
     289    int res = system(sCommand.ascii());
     290    if (WIFEXITED(res))
     291        res = WEXITSTATUS(res);
     292
     293    return res;
     294}
     295
    283296/** \fn cutDownString(const QString&, QFont*, uint)
    284297 *  \brief Returns a string based on "text" that fits within "maxwidth" pixels.
    285298 */
  • libs/libmyth/util.h

     
    5353MPUBLIC QRgb blendColors(QRgb source, QRgb add, int alpha);
    5454
    5555MPUBLIC uint myth_system(const QString &command, int flags = 0);
     56MPUBLIC bool isRunning(QString program);
    5657
    5758MPUBLIC QString cutDownString(const QString &text, QFont *testFont, uint maxwidth);
    5859