linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Yi Wang <yi.w@live.com>
To: linux-c-programming@vger.kernel.org
Subject: Signal handler and longjmp question
Date: Sun, 9 Dec 2007 21:12:20 +0800	[thread overview]
Message-ID: <BLU125-W33C6B6DA207B733BBC1F7AEA6A0@phx.gbl> (raw)
In-Reply-To: <S1751093AbXLIMzQ/20071209125516Z+241@vger.kernel.org>


Hi, all
    I read from some book that a signal handler can either return or call exit, abort or longjmp, it is permitted by ANSI C.
    However, I remember that lonjmp never returns, which in turn causes the signal handler can not return. In that case, the kernel will think the program is in signal handler forever, am I right? 
    IMHO, I think that is too bad...

Leo

--------------------------------------
code sample:

jmp_buf buf;
static void signal_handler(int signo)
{
    longjmp(buf);
}
int main()
{
  signal(SIGUSR1, signal_handler);
  ...
  setjmp(buf);
  ...
  return 0;
}

Suppose the program received SIGUSR1 after setjmp has been called, is the program still in signal handle context after longjmp?


_________________________________________________________________
Invite your mail contacts to join your friends list with Windows Live Spaces. It's easy!
http://spaces.live.com/spacesapi.aspx?wx_action=create&wx_url=/friends.aspx&mkt=en-us

       reply	other threads:[~2007-12-09 13:12 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <S1751093AbXLIMzQ/20071209125516Z+241@vger.kernel.org>
2007-12-09 13:12 ` Yi Wang [this message]
2007-12-09 14:06   ` Signal handler and longjmp question Steve Graegert
2007-12-10  6:03     ` Yi Wang

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=BLU125-W33C6B6DA207B733BBC1F7AEA6A0@phx.gbl \
    --to=yi.w@live.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).