Results 1 to 5 of 5

Thread: QProcess Standard Output

  1. #1
    Join Date
    Aug 2010
    Posts
    16
    Thanks
    3
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Unhappy QProcess Standard Output

    Hello, I am writing a utility in Qt 4.8 that basically automates several tasks for my area of software development. Some of the tools I am looking to automate require the usage of WINE. Everything is running as expected except when a tool requiring WINE encounters a logical error, it seems that I only receive errors from WINE itself and not the error information from the application running within WINE.

    Example:
    bash output:
    Qt Code:
    1. fixme:heap:HeapSetInformation (nil) 1 (nil) 0
    2. fixme:process:SetProcessDEPPolicy (1): stub
    3. fixme:heap:HeapSetInformation (nil) 1 (nil) 0
    4. fixme:heap:HeapSetInformation (nil) 1 (nil) 0
    5. fixme:module:GetModuleHandleExW should pin refcount for 0x79000000
    6. MMP: error MMP0000: Cannot locate file for assembly 'xxxx'
    7. MMP: error MMP0000: CLR_E_ENTRY_NOT_FOUND
    To copy to clipboard, switch view to plain text mode 

    QProcess output:
    Qt Code:
    1. fixme:heap:HeapSetInformation (nil) 1 (nil) 0
    2. fixme:process:SetProcessDEPPolicy (1): stub
    3. fixme:heap:HeapSetInformation (nil) 1 (nil) 0
    4. fixme:heap:HeapSetInformation (nil) 1 (nil) 0
    5. fixme:module:GetModuleHandleExW should pin refcount for 0x79000000
    To copy to clipboard, switch view to plain text mode 

    Now, in both cases I used the exact same command. My usage of QProcess is as follows:
    Qt Code:
    1. MainProcess = new QProcess(this);
    2. MainProcess->setProcessChannelMode(QProcess::MergedChannels);
    3. MainProcess->start(command,QIODevice::ReadWrite);
    4. if(!MainProcess->waitForFinished())
    5. {
    6. //handle errors
    7. }
    8. ui->textEdit->append(MainProcess->readAllStandardOutput());
    To copy to clipboard, switch view to plain text mode 

    readAllErrorOutput() returns nothing (as expected) and readAll() returns the exact same output as readAllStandardOutput().

    What am I doing wrong here? Any help would be greatly appreciated, thank you.

  2. #2
    Join Date
    Jul 2008
    Location
    Germany
    Posts
    507
    Thanks
    11
    Thanked 76 Times in 74 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QProcess Standard Output

    Hi, this looks like the WINE output is written to stdout, but the program's error is written to stderr.
    Have you tried QProcess::readAllStandardError() to read stderr?
    Maybe you can also try to write the messages to a file (QProcess::setStandardErrorFile() and QProcess::setStandardOutputFile()) and then read those files.

    Ginsengelf

    edit: it seems you already tried readAllStandardError()...

    edit2: are you sure your application does start and not only WINE? Did you separate the command (wine) and the arguments? I often got weird effects when I tried to pass the arguments together with the command in one QString. Use the overloaded start() method and pass the arguments as a QStringList, maybe this helps.
    Last edited by Ginsengelf; 15th August 2012 at 07:17.

  3. #3
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QProcess Standard Output

    It is possible the the "wine" program is spawning a child process with independent stdout/stderr streams.

  4. #4
    Join Date
    Aug 2010
    Posts
    16
    Thanks
    3
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QProcess Standard Output

    Quote Originally Posted by ChrisW67 View Post
    It is possible the the "wine" program is spawning a child process with independent stdout/stderr streams.
    If this is the case (as it seems the most logical) is there anyway for me grab or inherit the streams from the child process? I know that this is possible on Windows, but I am unsure about on Linux.

    Quote Originally Posted by Ginsengelf View Post
    Hi, this looks like the WINE output is written to stdout, but the program's error is written to stderr.
    Have you tried QProcess::readAllStandardError() to read stderr?
    Maybe you can also try to write the messages to a file (QProcess::setStandardErrorFile() and QProcess::setStandardOutputFile()) and then read those files.

    Ginsengelf

    edit: it seems you already tried readAllStandardError()...

    edit2: are you sure your application does start and not only WINE? Did you separate the command (wine) and the arguments? I often got weird effects when I tried to pass the arguments together with the command in one QString. Use the overloaded start() method and pass the arguments as a QStringList, maybe this helps.
    Yes, the "fixme" errors show that there is a stream of communication between wine and the application.

  5. #5
    Join Date
    Aug 2010
    Posts
    16
    Thanks
    3
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QProcess Standard Output

    I have come up with a temporary solution to my problem, however, this created another problem. I decided to try and echo the output to a file, and then parse that file during clean up. However, I can not issue an echo command that works for either echoing to a file or simply echoing to stdout. Upon googling this new issue, I found the same question was asked on another site, however the only answer given was "You should instead use QFile so you can tell if you have written any data or not.". While his point is valid, I obviously can not write nothing to a file through QFile. Is there special modes/enviroments I must set up to get echo to work properly?

Similar Threads

  1. Redirect standard output of external tools
    By nina1983 in forum Qt Programming
    Replies: 4
    Last Post: 14th June 2011, 10:09
  2. Replies: 2
    Last Post: 29th November 2009, 17:22
  3. Replies: 2
    Last Post: 2nd June 2008, 08:45
  4. redirection of standard input and output
    By guestgulkan in forum Qt Programming
    Replies: 2
    Last Post: 15th October 2006, 20:30
  5. QProcess +standard error + windows
    By antonio.r.tome in forum Qt Programming
    Replies: 0
    Last Post: 18th April 2006, 14:58

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.