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

  • Home
  • SEARCH
  • 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 8854443
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T13:52:54+00:00 2026-06-14T13:52:54+00:00

This is regarding the application that runs on POSIX (Linux) environment. Most signals (e.g.

  • 0

This is regarding the application that runs on POSIX (Linux) environment. Most signals (e.g. Ctrl+C – signal 2, SIGINT), and few others are handled. When that is done the exit() system call is called from the handler with a desirable exit code.

However, there are some signals like Signal 9 and Signal 15 can’t be handled.

Unfortunately, the parent process (an external script) which launches the given application needs to know and clean up some stuff if the signal 9 or 15 was the reason for termination.

Is there a predefined exit code that can be received by parent process to know the above?

The script that launches the app is a bash_script. The application itself is in C.

  • 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-14T13:52:55+00:00Added an answer on June 14, 2026 at 1:52 pm

    The return status from wait() or waitpid() encodes the information you need.

    The POSIX macros are:

    • WIFEXITED(status) returns true if the child exited via exit() or one of its relatives.
    • WEXITSTATUS(status) tells you what that exit status was (0..255).
    • WIFSIGNALED(status) returns true if the child exited because of a signal (any signal).
    • WTERMSIG(status) returns the signal number that killed the child.

    The non-standard but common macro WCOREDUMP(status) tells you if the process dumped core. You can also tell whether status reflect that the process was stopped, or continued (and what the stop signal was).

    Note that signal 15 is usually SIGTERM and SIGTERM can be trapped by an application. The signals that cannot be trapped are SIGKILL (9) and SIGSTOP (17 on Mac OS X; may not be the same everywhere).


    The question then is if bash provides this info for a script.

    The answer is yes, but only indirectly and not 100% unambiguously. The status value reported by bash will be 128 + <signum> for processes that terminate due to signal <signum>, but you can’t distinguish between a process that exits with status 130, say, and a process that was interrupted by SIGINT, aka signal 2.

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

Sidebar

Related Questions

Some background, this application is a printing application that runs within REvit Structure, an
I'm sort of lost on this. I have an application that is reading from
This is regarding a project that concerns detection of text in an image using
I am writing an application that runs in the background from startup to shutdown,
I have a spring application that has configured log4j (via xml) and that runs
I'm trying to write an application that runs as a daemon and monitors running
I have a web application that runs multiple websites from one codebase. I have
I have an application that uses the Ent Lib 4.1 logging application block. This
I maintain a legacy application that runs on PHP/5.2.6 under Windows Server 2003 and
I have a QT C++ application that runs the Octave program using QProcess. I

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.