这是什么搞法?
在 StdoutRedirector 里竟然看到了 :
connect(pipeReader, SIGNAL(readyRead()), this, SIGNAL(readyRead()));
StdoutRedirector::StdoutRedirector(QObject *parent, ProcessChannels channels) :
QObject(parent), m_channels(channels)
{
#ifdef Q_OS_WIN
createWinPipe(hRead, hWrite);
if (m_channels & StandardOutput)
::SetStdHandle(STD_OUTPUT_HANDLE, hWrite);
if (m_channels & StandardError)
::SetStdHandle(STD_ERROR_HANDLE, hWrite);
int fd = _open_osfhandle((intptr_t)hWrite, _O_WRONLY|_O_TEXT);
if (m_channels & StandardOutput)
_dup2(fd, 1);
if (m_channels & StandardError)
_dup2(fd, 2);
_close(fd);
pipeReader = new QWindowsPipeReader(this);
pipeReader->setHandle(hRead);
pipeReader->startAsyncRead();
connect(pipeReader, SIGNAL(readyRead()), this, SIGNAL(readyRead()));
#else
::pipe(pipeEnds);
if (m_channels & StandardOutput)
::dup2(pipeEnds[1], 1);
if (m_channels & StandardError)
::dup2(pipeEnds[1], 2);
::close(pipeEnds[1]);
buffer = new QRingBuffer();
socketNotifier = new QSocketNotifier(pipeEnds[0], QSocketNotifier::Read, this);
connect(socketNotifier, SIGNAL(activated(int)), this, SLOT(onSocketActivated()));
#endif
}