Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8960123
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T15:36:10+00:00 2026-06-15T15:36:10+00:00

I am trying to generate a subprocess for a gui which will spawn a

  • 0

I am trying to generate a subprocess for a gui which will spawn a terminal. I want the data produced by this terminal (stdout and stderr) to be displayed on the window that appears as well as to a set log file. When I type the command directly in to a shell it works as intended, but when provided to a QProcess as a start command it doesn’t actually write anything to the file.

For example: if the user doesn’t have the binaries installed it should write to bin.log that the command was not found. I have set my environment for the spawned QProcess to be the same as the running parent process (so that it can find bash and anything else), and have set the working directory before calling QProcess.start() method. I wrote a test case which follows:

gnome-terminal --title 'Sub-Terminal' -e 'bash -c "foo [args to foo] |& tee foo.log"'

In Qt I do the following:

QProcess *child = new QProcess(this);
QString   cmd   = "gnome-terminal --title 'Sub-Terminal' -e 'bash -c \"foo [args to foo] |& tee foo.log\"'";
child->setProcessEnvironment(<process environment I have created before>);
child->setWorkingDirectory(<current working dir>);
child->start(cmd);
...

It generates the terminal but does not write any data to foo.log. I have also tried the following:

QProcess *child = new QProcess(this);
QString   prog  = "gnome-terminal"
QStringList args;
args << "-x" << "bash" << "foo" << "[foo's arguments]" << "|&" << "tee" << "foo.log";
// set the process env and working dir
child->start(prog, args);

Does anyone have any advice on how to solve this?
I have tried redirecting stdout and stderr using QProcess.setStandardErrorFile(foo.log) and QProcess.setStandardOutputFile(foo.log), but it seems like that would be redirecting the stdout from the gnome-terminal itself (which isn’t anything).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T15:36:11+00:00Added an answer on June 15, 2026 at 3:36 pm

    You have to provide the whole command to be executed in the terminal as one single argument to QProcess after "-e", as well as the command to be executed in bash as one single argument to bash:

    args << "-e" << "bash -c 'foo [args to foo] |& tee foo.log'";
    

    This basically executes

    bash -c 'foo [args to foo] |& tee foo.log'
    

    in the terminal, which by itself executes

    foo [args to foo] |& tee foo.log
    

    within bash.

    You are right with your guess that reading the outputs from the gnome-terminal process doesn’t work.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I trying to generate an XML document which is around 23 to 30 MB,
I am trying to generate a log file with information in order. This is
I'm trying to generate some LaTeX code which from thereon should generate PDF documents.
I am trying to generate a Data On Demand class for one of my
Trying to generate db driven menu which based on parent->child structure. All root menu
I'm trying to generate the MD5 Fingerprint I will use with the release of
I am trying to generate a schema from this xml file: http://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?rettype=xml&retmode=xml&db=nucleotide&id=AB573763 I store
I am trying to generate a PDF using iTextSharp. It will consists of a
I'm trying to generate a proxy class with WCF which, when serialized, converts and
while trying to generate a proxy from this WebService (http://scdemo14.infor.com:9014/axis/services/wb:wsclocks-inbound?wsdl) I'm receiving this error

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.