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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T23:35:28+00:00 2026-05-23T23:35:28+00:00

I have one simple program that’s using Qt Framework. It uses QProcess to execute

  • 0

I have one simple program that’s using Qt Framework.
It uses QProcess to execute RAR and compress some files. In my program I am catching SIGINT and doing something in my code when it occurs:

signal(SIGINT, &unix_handler);

When SIGINT occurs, I check if RAR process is done, and if it isn’t I will wait for it … The problem is that (I think) RAR process also gets SIGINT that was meant for my program and it quits before it has compressed all files.

Is there a way to run RAR process so that it doesn’t receive SIGINT when my program receives it?

Thanks

  • 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-23T23:35:29+00:00Added an answer on May 23, 2026 at 11:35 pm

    If you are generating the SIGINT with Ctrl+C on a Unix system, then the signal is being sent to the entire process group.

    You need to use setpgid or setsid to put the child process into a different process group so that it will not receive the signals generated by the controlling terminal.


    [Edit:]

    Be sure to read the RATIONALE section of the setpgid page carefully. It is a little tricky to plug all of the potential race conditions here.

    To guarantee 100% that no SIGINT will be delivered to your child process, you need to do something like this:

    #define CHECK(x) if(!(x)) { perror(#x " failed"); abort(); /* or whatever */ }
    /* Block SIGINT. */
    sigset_t mask, omask;
    sigemptyset(&mask);
    sigaddset(&mask, SIGINT);
    CHECK(sigprocmask(SIG_BLOCK, &mask, &omask) == 0);
    
    /* Spawn child. */
    pid_t child_pid = fork();
    CHECK(child_pid >= 0);
    if (child_pid == 0) {
        /* Child */
        CHECK(setpgid(0, 0) == 0);
        execl(...);
        abort();
    }
    /* Parent */
    if (setpgid(child_pid, child_pid) < 0 && errno != EACCES)
        abort(); /* or whatever */
    /* Unblock SIGINT */
    CHECK(sigprocmask(SIG_SETMASK, &omask, NULL) == 0);
    

    Strictly speaking, every one of these steps is necessary. You have to block the signal in case the user hits Ctrl+C right after the call to fork. You have to call setpgid in the child in case the execl happens before the parent has time to do anything. You have to call setpgid in the parent in case the parent runs and someone hits Ctrl+C before the child has time to do anything.

    The sequence above is clumsy, but it does handle 100% of the race conditions.

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

Sidebar

Related Questions

We have an app that uses simple one way binding with a GridView to
I have found that on one simple program, I was able to add the
Suppose i have one simple function in my program. Whenever i call that function
Im sure this will be a simple one but have a project that started
I have a really simple class with two methods; One that will be called
Simple idea: I have two images that I want to merge, one is 500x500
We have a fairly simple program that's used for creating backups. I'm attempting to
I have been trying to create a simple program with Python which uses OpenCV
I have a script that appends some rows to a table. One of the
I have a simple program that takes an ID number and prints information for

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.