24 const Hdc &hdc,
const QString &devicePath,
const QString &bundleName)
26 static constexpr int startTimeoutMs = 5000;
28 const QString followFileFromStart = u"sz=0; f='"_s + devicePath + u"';"_s;
29 const QString definePrintNewBytes =
30 u" dump() { new=$(wc -c < \"$f\" 2>/dev/null);"
31 " if [ \"${new:-0}\" -gt \"$sz\" ]; then"
32 " tail -c +$((sz+1)) \"$f\" 2>/dev/null | head -c $((new-sz)); sz=$new; fi; };"_s;
33 const QString printNewBytesUntilAppExits =
34 u" while true; do dump;"
35 " pidof "_s + bundleName + u" >/dev/null 2>&1 || { dump; break; };"
37 const QString streamUntilAppExits =
38 followFileFromStart + definePrintNewBytes + printNewBytesUntilAppExits;
40 auto process = std::make_unique<QProcess>();
42 process->setProcessChannelMode(QProcess::SeparateChannels);
43 process->start(hdc.program(), hdc.shellArguments({streamUntilAppExits}));
44 if (!process->waitForStarted(startTimeoutMs))