mirror of
https://github.com/badaix/snapcast.git
synced 2025-05-17 11:06:16 +02:00
fixed crash on stop
non-blocking read
This commit is contained in:
parent
e0d9de5904
commit
a98629563f
1 changed files with 7 additions and 2 deletions
|
@ -19,6 +19,7 @@
|
||||||
|
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
#include <fcntl.h>
|
||||||
#include "processStream.h"
|
#include "processStream.h"
|
||||||
#include "common/snapException.h"
|
#include "common/snapException.h"
|
||||||
#include "common/utils.h"
|
#include "common/utils.h"
|
||||||
|
@ -39,7 +40,8 @@ ProcessStream::ProcessStream(PcmListener* pcmListener, const StreamUri& uri) : P
|
||||||
|
|
||||||
ProcessStream::~ProcessStream()
|
ProcessStream::~ProcessStream()
|
||||||
{
|
{
|
||||||
process_->kill();
|
if (process_)
|
||||||
|
process_->kill();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -138,6 +140,9 @@ void ProcessStream::worker()
|
||||||
while (active_)
|
while (active_)
|
||||||
{
|
{
|
||||||
process_.reset(new Process(exe + " " + params, path));
|
process_.reset(new Process(exe + " " + params, path));
|
||||||
|
int flags = fcntl(process_->getStdout(), F_GETFL, 0);
|
||||||
|
fcntl(process_->getStdout(), F_SETFL, flags | O_NONBLOCK);
|
||||||
|
|
||||||
stderrReaderThread_ = thread(&ProcessStream::stderrReader, this);
|
stderrReaderThread_ = thread(&ProcessStream::stderrReader, this);
|
||||||
stderrReaderThread_.detach();
|
stderrReaderThread_.detach();
|
||||||
|
|
||||||
|
@ -190,7 +195,7 @@ void ProcessStream::worker()
|
||||||
{
|
{
|
||||||
logE << "Exception: " << e.what() << std::endl;
|
logE << "Exception: " << e.what() << std::endl;
|
||||||
process_->kill();
|
process_->kill();
|
||||||
chronos::sleep(100);
|
chronos::sleep(1000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue