linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Glynn Clements <glynn@gclements.plus.com>
To: kaushal@rocsys.com
Cc: linux-c <linux-c-programming@vger.kernel.org>
Subject: Re: SIGSEGV
Date: Fri, 4 Mar 2005 00:33:22 +0000	[thread overview]
Message-ID: <16935.44242.116101.200958@gargle.gargle.HOWL> (raw)
In-Reply-To: <1109766028.5107.5.camel@localhost.localdomain>


kaushal wrote:

> 	I have big package which "must" run all the time irrespective of any
> errors.As a part of that Iam even handling the SIGSEGV.The problem is
> even if I handle the sigsegv,the handler gets called continuously in an
> infinite loop as if the signal is being recvd. continuously.How can I
> solve this issue and make my handle run only once?

Install the handler using sigaction() with the SA_RESETHAND flag. When
the signal is received, the handler will be de-installed; if SIGSEGV
is received again, the program will be terminated.

The fact that your program received SIGSEGV suggests that one or more
variables contain an invalid value. If you attempt to resume execution
without fixing the error, you will just get further SIGSEGVs.

More generally, if you detect that your program has got into an
invalid state, you have two reasonable choices: either give up (i.e.
terminate) or correct the problem.

Ignoring the problem and hoping that that the program will magically
recover isn't going to work.

A more realistic approach for programs which need to run continuously
would be to run the program from init with the "respawn" option; if
the program terminates, init will restart it.

-- 
Glynn Clements <glynn@gclements.plus.com>

      parent reply	other threads:[~2005-03-04  0:33 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-03-02 12:20 SIGSEGV kaushal
2005-03-02 13:48 ` SIGSEGV mohana sundaram
2005-03-02 14:24   ` SIGSEGV Ron Michael Khu
2005-03-04  0:33 ` Glynn Clements [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=16935.44242.116101.200958@gargle.gargle.HOWL \
    --to=glynn@gclements.plus.com \
    --cc=kaushal@rocsys.com \
    --cc=linux-c-programming@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).