Results 1 to 6 of 6

Thread: Destroyed while process is still running

  1. #1
    Join Date
    Jun 2009
    Posts
    38
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Destroyed while process is still running

    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:rocessEvents();
    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 -

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Destroyed while process is still running

    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.

  3. #3
    Join Date
    Jun 2009
    Posts
    38
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Destroyed while process is still running

    Can you kindly explain a little what u mean by that 'heap'?

  4. #4
    Join Date
    Jun 2009
    Posts
    38
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Destroyed while process is still running

    I tried
    Qt Code:
    1. QProcess *process1 = new QProcess(parent);
    To copy to clipboard, switch view to plain text mode 

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

  5. #5
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Destroyed while process is still running

    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.

  6. #6
    Join Date
    Jun 2009
    Posts
    38
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Destroyed while process is still running

    Ah, following was the problem

    Qt Code:
    1. QString command2 = "netcat ";
    To copy to clipboard, switch view to plain text mode 

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

    Sorry to bother you all.

Similar Threads

  1. Replies: 1
    Last Post: 18th May 2009, 10:49
  2. Connecting with QProcess to an already running process
    By high_flyer in forum Qt Programming
    Replies: 7
    Last Post: 26th November 2007, 11:31
  3. QThread: Destroyed while thread is still running
    By Shuchi Agrawal in forum Newbie
    Replies: 8
    Last Post: 3rd April 2007, 07:27
  4. Check wheter a process is running
    By Lele in forum Qt Programming
    Replies: 1
    Last Post: 15th June 2006, 13:35
  5. QProcess / system call not working under linux. Why?
    By johnny_sparx in forum Qt Programming
    Replies: 12
    Last Post: 11th March 2006, 01:32

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.