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 7642171
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T09:07:19+00:00 2026-05-31T09:07:19+00:00

Hi I am working on Linux and I am trying to create a GUI

  • 0

Hi I am working on Linux and I am trying to create a GUI app to go with my executable I have made.

For some reason it unexpectedly ends. There is no error message, it just says in the Qt console window it unexpectedly ended with exit code 0.

Can someone please have a look at it for me. I am working on Linux.

I will also paste the code here.

void MainWindow::on_pushButton_clicked()
{
    QString stringURL = ui->lineEdit->text();

    ui->labelError->clear();
    if(stringURL.isEmpty() || stringURL.isNull()) {
        ui->labelError->setText("You have not entered a URL.");
        stringURL.clear();
        return;
    }

    std::string cppString = stringURL.toStdString();
    const char* cString = cppString.c_str();

    char* output;

    //These arrays will hold the file id of each end of two pipes
    int fidOut[2];
    int fidIn[2];

    //Create two uni-directional pipes
    int p1 = pipe(fidOut);                //populates the array fidOut with read/write fid
    int p2 = pipe(fidIn);                 //populates the array fidIn  with read/write fid
    if ((p1 == -1) || (p2 == -1)) {
        printf("Error\n");
        return;
    }

    //To make this more readable - I'm going to copy each fileid
    //into a semantically more meaningful name
    int parentRead  = fidIn[0];
    int parentWrite = fidOut[1];
    int childRead   = fidOut[0];
    int childWrite  = fidIn[1];

    //////////////////////////
    //Fork into two processes/
    //////////////////////////
    pid_t processId = fork();

    //Which process am I?
    if (processId == 0) {
        /////////////////////////////////////////////////
        //CHILD PROCESS - inherits file id's from parent/
        /////////////////////////////////////////////////
        ::close(parentRead);      //Don't need these
        ::close(parentWrite);     //

        //Map stdin and stdout to pipes
        dup2(childRead,  STDIN_FILENO);
        dup2(childWrite, STDOUT_FILENO);

        //Exec - turn child into sort (and inherit file id's)
        execlp("htmlstrip", "htmlstrip", "-n", NULL);

    } else {
        /////////////////
        //PARENT PROCESS/
        /////////////////
        ::close(childRead);       //Don't need this
        ::close(childWrite);      //

        //Write data to child process
        //char strMessage[] = cString;
        write(parentWrite, cString, strlen(cString));
        ::close(parentWrite);     //this will send an EOF and prompt sort to run

        //Read data back from child
        char charIn;
        while ( read(parentRead, &charIn, 1) > 0 ) {
            output = output + (charIn);
            printf("%s", output);
        }
        ::close(parentRead);      //This will prompt the child process to quit
    }

    return;
}

EDIT:: DEBUGGING RESULTS

I ran the debugger and this is the error I received:

The inferior stopped because it received a signal from the Operating System.

Signal name : SIGSEGV
Signal meaning : Segmentation fault
  • 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-05-31T09:07:20+00:00Added an answer on May 31, 2026 at 9:07 am

    You haven’t initialized the “output” variable. On the last lines of your code, you do this:

    while ( read(parentRead, &charIn, 1) > 0 ) {
        output = output + (charIn);
        printf("%s", output);
    }
    

    Which will do nasty things, since you are adding a byte read from your child process, to the output variable, which is a pointer that contains garbage, and then printing the contents of the “output” variable’s address as a string. You probably want “output” to be a std::string, that way your code could make sense:

    std::string output;
    /* ... */
    while ( read(parentRead, &charIn, 1) > 0 ) {
        output += (charIn);
    }
    std::cout << output;
    

    Once you have read all the data your child process has generated, you can write it to stdout.

    EDIT: since you want to set the contents of “output” to a QPlainTextEdit, you can use QPlainTextEdit::setPlainText:

    while ( read(parentRead, &charIn, 1) > 0 ) {
        output += (charIn);
    }
    plainTextEdit.setPlainText(output.c_str());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi there I am trying to create a bug-free jquerymobile app across Android Browser,
I'm trying to port a GTK-based Linux app to Mac OS-X. I have the
I'm trying to get a global hotkey working in Linux using Mono. I found
i am new in programming under linux and trying to get working this code:
I have a (from what I can tell) perfectly working Linux setup (Ubuntu 8.04)
Actually I have a file . I am working in linux environment. I need
I'm working on a Linux based server system in which there are two network
I have set up WebDAv server on my Debian linux and this is working
I am trying to find out MAC address and I managed to create working
I am trying to create a file in the /tmp directory (working on a

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.