Ticket #6830: lcd_cloexec.patch

File lcd_cloexec.patch, 1.1 KB (added by foobum@…, 11 years ago)
  • mythtv/libs/libmythdb/lcddevice.cpp

    diff --git a/mythtv/libs/libmythdb/lcddevice.cpp b/mythtv/libs/libmythdb/lcddevice.cpp
    index 06682ab..2406438 100644
    a b  
    1212#include <cmath>
    1313
    1414// POSIX headers
     15#include <fcntl.h>
    1516#include <unistd.h>
    1617
    1718// Qt headers
     
    2021#include <QTextStream>
    2122#include <QTextCodec>
    2223#include <QByteArray>
     24#include <QDir>
     25#include <QStringList>
    2326
    2427// MythTV headers
    2528#include "lcddevice.h"
    bool LCD::connectToHost(const QString &lhostname, unsigned int lport) 
    137140
    138141    if (res == 0)
    139142    {
     143#ifndef _WIN32
     144        QDir dir = QDir("/proc/self/fd");
     145        QStringList files = dir.entryList(QDir::Files|QDir::System, QDir::Name);
     146        QStringList::const_iterator it;
     147
     148        for (it = files.constBegin(); it != files.constEnd(); ++it) {
     149            if ((*it).startsWith("."))
     150                continue;
     151            fcntl((*it).toInt(), F_SETFD, FD_CLOEXEC);
     152        }
     153#endif
    140154        // we need to start the mythlcdserver
    141155        VERBOSE(VB_GENERAL, "Starting mythlcdserver");
    142156