Ticket #9194: mythfilldatabase.exit-status.diff

File mythfilldatabase.exit-status.diff, 2.5 KB (added by Sverker Wiberg <sverkerw@…>, 13 years ago)
  • filldata.cpp

     
    430430
    431431    QByteArray tmp = command.toAscii();
    432432    int systemcall_status = system(tmp.constData());
    433     bool succeeded = WIFEXITED(systemcall_status) &&
    434          WEXITSTATUS(systemcall_status) == 0;
    435433
    436434    VERBOSE(VB_XMLTV,
    437435            "------------------ End of XMLTV output ------------------");
    438436
    439437    updateLastRunEnd(query);
    440438
    441     status = QObject::tr("Successful.");
    442 
    443     if (!succeeded)
     439    bool succeeded = false;
     440 
     441    if (WIFEXITED(systemcall_status))
    444442    {
    445         if (WIFSIGNALED(systemcall_status) &&
    446             (WTERMSIG(systemcall_status) == SIGINT
    447             || WTERMSIG(systemcall_status) == SIGQUIT))
     443        if (WEXITSTATUS(systemcall_status) == 0)
    448444        {
    449             interrupted = true;
    450             status = QString(QObject::tr("FAILED: xmltv ran but was interrupted."));
     445            succeeded = true;
     446            status = QObject::tr("Successful.");
    451447        }
    452448        else
    453449        {
    454             status = QString(QObject::tr("FAILED: xmltv returned error code %1."))
    455                             .arg(systemcall_status);
    456             VERBOSE(VB_IMPORTANT, LOC_ERR +
    457                     QString("xmltv returned error code %1")
    458                     .arg(systemcall_status));
     450            status = QObject::tr("xmltv exited with non-zero exit status %1.")
     451                .arg(WEXITSTATUS(systemcall_status));
    459452        }
    460453    }
     454    else if (WIFSIGNALED(systemcall_status))
     455    {
     456        if (WTERMSIG(systemcall_status) == SIGINT
     457            || WTERMSIG(systemcall_status) == SIGQUIT)
     458        {
     459            interrupted = true;
     460            status = QObject::tr("xmltv ran but was interrupted.");
     461         }
     462        else
     463        {
     464            status = QObject::tr("xmltv killed by signal %1.")
     465                .arg(WTERMSIG(systemcall_status));
     466        }
     467    }
     468    else
     469    {                // cannot parse the status; this shouldn't happen
     470        status = QObject::tr("xmltv exited with termination status %1.")
     471            .arg(systemcall_status);
     472    }
     473   
     474    if (WCOREDUMP(systemcall_status))
     475    {
     476        status += QObject::tr(" (Core dumped.)");
     477    }
    461478
     479    if (!succeeded)
     480    {
     481        if (!interrupted)
     482        {
     483            VERBOSE(VB_IMPORTANT, LOC_ERR + status);
     484        }
     485        status.prepend(QObject::tr("FAILED: "));
     486    }
     487
    462488    updateLastRunStatus(query, status);
    463489
    464490    succeeded &= GrabDataFromFile(source.id, filename);