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

The Archive Base Latest Questions

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

How to be noticed if calling a program caused segmentation fault in a linux

  • 0

How to be noticed if calling a program caused segmentation fault in a linux bash script, probably to stop the script then?

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

    If the program exits with a segmentation fault, or any other error, it will exit with a non-zero exit code. You can test this exit code, and exit your script when it does so. If you want to stop on any error (not just segmentation fault), you can use:

    some-crashy-program args || exit 1
    

    If you want to exit your script if any program that you call returns an error (except for as part of an if or while statement), you can just call set -e at the beginning of your script, to cause the script to exit immediately if any command fails. This usage is somewhat discouraged in larger scripts that need to be maintained over time, since it can lead to your script exiting at an unexpected time if something like grep returns a non-zero exit code, but it can be useful for quick one-off scripts if you know that you always want to stop on error.

    If you only want to exit if the program crashed with a segfault, not any other error, you can check the specific exit code. On most systems, SEGV has value 11, but you can check with:

    $ kill -l SEGV
    11
    

    Then add 128 to that, and that will be the exit code your program exits with. Test the exit code against that to find out if your program crashed with SIGSEGV:

    some-crashy-program args
    if [ $? -eq 139 ]; then
        echo "It crashed!"
        exit 1
    fi
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

While following path for wait system call, noticed that before calling do_wait_thread we get
I noticed that calling the printf function (with cl_intel_printf extension), the same variable of
I've noticed that in my program when I look away from my tessellated mesh,
We have noticed a weird error when calling ToLower() on certain strings. The input
Browsing the ruleby source code, I noticed that they were calling Container(:and) , which
i noticed that mingw adds alot of code before calling main(), i assumed its
I have noticed many code examples of calling a web service which returns json
I'm calling a .net webservice from Linux using Perl (5.8.7). I'm using the SOAP::Lite
I noticed that calling createEntityManagerFactory(null) will use the default Persistence Unit (PU) in the
I am writing a script that calls another java program, to perform some tasks.

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.