PDA

View Full Version : Destroyed while process is still running



qtzcute
21st July 2009, 20:28
I am actually sending memory image from one machine to another. When i do it in simple shell it works fine.

Client's Shell: netcat -l -p 9001 | dd of=mem.img
Server's Shell: dd if=/dev/mem | netcat 192.168.25.76 9001

where 192.168.25.76 is the IP address of client and 9001 is the port number. I first run the piped command on client and then the server's. Image gets transfer smoothly.

But now i am trying to provide a GUI for the server. Such that the user will have to enter only ip address in the lineEdit. The client however runs in shell as earlier. I used following code but its giving the said message while not transferring anything.

....
QObject::connect(pushButton_send, SIGNAL(clicked()), MainWindow, SLOT(sendImage()));
....
void MainWindow::sendImage()
{
QObject *parent;

QString command1 = "dd if=/dev/mem";
QString command2 = "netcat ";
QStringList arguments;
arguments<<lineEdit_ipAddr->text()<<"9001";
QProcess process1;
QProcess *process2 = new QProcess(parent);

process1.setStandardOutputProcess(process2);
QCoreApplication::processEvents();
process1.start(command1);
process2->start(command2, arguments);
}

Any suggestions for me? Btw if i use process1.error() or process2->error(), both return integer value 5 representing 'Unknown Error'.

Please help.
- Show quoted text -

Lykurg
21st July 2009, 20:59
Processes are started asynchronously, so create your process1 on the heap. You also should use a valid parent for them or ensure you delete them properly.

qtzcute
22nd July 2009, 03:40
Can you kindly explain a little what u mean by that 'heap'?

qtzcute
22nd July 2009, 04:35
I tried

QProcess *process1 = new QProcess(parent);

but that too did not solve the problem. No data is transferring.

Lykurg
22nd July 2009, 08:27
Either you use QProcess::waitForFinished(), then you can use the stack, or you use a slot connected with QProcess::finished(), but then your processes have to be on the heap.

qtzcute
23rd July 2009, 09:26
Ah, following was the problem


QString command2 = "netcat ";

There is a <space> after the letter 't' in netcat.

Sorry to bother you all. :o