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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T19:46:55+00:00 2026-06-09T19:46:55+00:00

In the below code, when system function get executed (in Linux and compiled with

  • 0

In the below code, when system function get executed (in Linux and compiled with g++), it will send the SIGCHLD signal to process (from which it is called) which doesn’t happen in Solaris code. I mean, if I run the same code in Solaris, the system function doesn’t send any signal to the process from which it is called. As a result, my process in Linux hangs.

#include <iostream>
using namespace std;
#include <cstdlib>
#include <signal.h>

void sigHandler(int sgnNbr)
{
    cout <<"Signal " << sgnNbr << "caught" << endl;
    system("echo $HOSTNAME");
    exit(1);
}

int main()
{
    signal(SIGCHLD,sigHandler);
    system("echo $HOSTNAME");
    return 0;
}  

My questions are:

  1. Why does the process hang in the above case?
  2. why does the system function not send any signal in Solaris?

… and my last question, which is related to my real application:

Actually, in my real application (in which single signal handler is there for some four signals), some other process sending the SIGABRT signal to my process and in signal handler I am killing the one process using system function as a result it got hanged(which is similar to the above scenario). Is there any way to overcome this?

  • 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-09T19:46:57+00:00Added an answer on June 9, 2026 at 7:46 pm

    From http://pubs.opengroup.org/onlinepubs/009604499/functions/system.html:

    The system() function shall ignore the SIGINT and SIGQUIT signals, and shall block the SIGCHLD signal, while waiting for the command to terminate.

    Solaris is correct; Linux is incorrect.

    The most likely reason that your program is hanging is that it is not safe to call system within a signal handler. See http://pubs.opengroup.org/onlinepubs/009604499/functions/xsh_chap02_04.html#tag_02_04 for the list of async-signal-safe functions.

    To kill another process, you can use kill, which is async-signal-safe.

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

Sidebar

Related Questions

Here i used below in code on linux. using cp command in system function.
I am using below code to get & process value from google HashMultimap HashMultimap
I am using the code below to get processor id: System.Management.ManagementClass theClass = new
The code below is what I am using to send and receive information from
Anyone know what's going wrong with below code? The system will only call the
I tried accessing web for xml parsing using the code below: System.Uri proxy =
The code below is in C# and I'm using Visual Studio 2010. using System;
I’m getting system error when I try to compile the code below on Visual
My code looks like below: private void LayoutRoot_Loaded(object sender, System.Windows.RoutedEventArgs e) { // TODO:
below code is my databasehandler class i got it from a tutorial. Beside that

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.