Results 1 to 5 of 5

Thread: Shell script crash launched by QProcess, works launched manually

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Apr 2014
    Posts
    4
    Qt products
    Qt5
    Platforms
    Windows

    Default Shell script crash launched by QProcess, works launched manually

    Hi,

    I'm on intership for a research lab, my duty is to provide a GUI for a good algorithm that until now needs to be launched and parametered console-style. I need to launch a heavy-processing shell script through GUI.

    I use QtCreator 2.8.1 based on Qt 5.1.1, along with MinGW 4.8 and MSYS 1.0.17.

    Yet I'm trying to launch the script through a QProcess with this syntax :

    MainWindow.cpp
    Qt Code:
    1. void MainWindow::on_pushButton_clicked() {
    2.  
    3. process = new QProcess(this);
    4. process->setProcessChannelMode(QProcess::MergedChannels);
    5. connect(process, SIGNAL(readyReadStandardOutput()), this, SLOT(displayLog()));
    6.  
    7. QString command = "sh ./myscript.sh";
    8. process->start(command);
    9.  
    10. }
    To copy to clipboard, switch view to plain text mode 

    With process declared as a QProcess*, displayLog() appending the output to a QPlainTextEdit and $PATH knowing MSYS/bin

    The script runs, the log displays but in the stderr output it shows that at one point there's a memory allocation problem within one of the scripts crashing most of its functionnalities.

    The nasty thing is that when I open cmd.exe and execute manually "sh ./myscript.sh", this allocation problem doesn't appear. I've tried to launch process->start("cmd /K start sh ./myscript.sh"), result is the same. Also with startDetached, everytime the script is launched through Qt it crashes.

    My question is : is there a memory limitation for a QProcess on the heap ? Is there a way to extend the memory allocated to a QProcess ? What in the QProcess architecture could prevent a sh command to work the same as launched manually ? I've read the QProcess official doc aswell as many forum threads but couldn't find any hints, it's turning me crazy.

    Thanks for your answers ! And overall thanks to the community, this forum is really useful on a daily-basis.

    Edit: myscript.sh is a launcher that execute a bunch of others .sh, which end executing a fortran core algorithm.

    Edit: the error message about a bad allocation is internally wrote in a script. It says : Allocation error var1->var2 in function COM_init.c, 805 306 368 bytes needed
    Last edited by Mansurji; 17th April 2014 at 15:24.

Similar Threads

  1. Replies: 11
    Last Post: 5th July 2011, 11:11
  2. Replies: 5
    Last Post: 10th January 2011, 00:19
  3. QProcess: how to run shell script with password?
    By cutie.monkey in forum Qt Programming
    Replies: 0
    Last Post: 23rd March 2010, 05:43
  4. Driver loaded only when launched from Creator
    By vieraci in forum Qt Tools
    Replies: 0
    Last Post: 16th September 2009, 02:56
  5. Qt Public Repository Launched!
    By lpotter in forum Qt Programming
    Replies: 1
    Last Post: 12th May 2009, 00:38

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.