Unsolved Qprocess
-
HI friends,
I am rsync with Qprocess in normal function it is Working fine rsync when i run thread rsync not what is problem can any body give soultion below is my code.
void myRunrsync()
{
bool bRemote =true;
QString pFileName = "yazmi@192.168.0.103:/home/yazmi/YazmiFileRepository/FiletoTransmit/Test222.pdf";
QProcess rsync_shProcess = new QProcess();
if(!pFileName.isNull())
{
QStringList m_nList;
QString m_sBandWidth ="--bwlimit="+QString::number(UPLOAD_BITRATE);
QString m_sPassword = "yazmi2019";
QString pDestName = "/home/yazmi/Documents/";
/ if(bRemote)
{
m_nList<< " rsync -rP "<< pFileName << pDestName << m_sBandWidth << " -e" << " 'sshpass -p " "+m_sPassword
+"" ssh -p "+ QString::number(DEFAULT_SSH_PORT)+"'";
}
else
{
m_nList<<"rsync -rP " << pFileName << pDestName << m_sBandWidth;
//}*/// rsync_shProcess->start("sh",QStringList()<< " rsync -rP "<< pFileName << pDestName << m_sBandWidth << " -e" << " 'sshpass -p \" "+m_sPassword // +"\" ssh -p "+ QString::number(DEFAULT_SSH_PORT)+"'"); // rsync_shProcess->start("sh",QStringList()<<"rsync -rP " << pFileName << pDestName << m_sBandWidth); rsync_shProcess->start("sh"); rsync_shProcess->setProcessChannelMode(QProcess::MergedChannels); QString command = "rsync -rP "+pFileName+" "+pDestName+" "+m_sBandWidth+ " -e 'sshpass -p \""+m_sPassword +"\" ssh -p "+ QString::number(DEFAULT_SSH_PORT)+"'"; qDebug().noquote() << "command:" << command; //rsync_shProcess->start(command); rsync_shProcess->write(command.toStdString().c_str()); rsync_shProcess->closeWriteChannel(); }
}
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);myRunrsync();
//QFuture<void> t1 = QtConcurrent::run(myRunrsync);
}
when i call function myRunrsync() it is working.
when i run with thread QFuture<void> t1 = QtConcurrent::run(myRunrsync); it is not working what may be the problem. -
Why should "QFuture<void> t1 = QtConcurrent::run(myRunrsync);" work when you quit the application right afterwards?
Why do you want to run a QProcess in a separate thread at all - it's async... -
it is testing example in real time scenario it should be in thread multiple r sync will run so it should in different threads.
-
@satyanarayana143 said in Qprocess:
in real time scenario it should be in thread multiple r sync will run so it should in different threads
Not necessarily. You can create & launch multiple separate
QProcess
instances, all from your main thread. Each of those will obviously run the process (rsync
) separately. They will all be asynchronous. So it's not evident that your code itself will need to create any threads for eachQProcess
.