summaryrefslogtreecommitdiff
path: root/imap4d/signal.c
blob: 7a98b9dc87e3804ff0c724e76dd3c7e427ac509b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/* GNU Mailutils -- a suite of utilities for electronic mail
   Copyright (C) 1999-2021 Free Software Foundation, Inc.

   GNU Mailutils is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 3, or (at your option)
   any later version.

   GNU Mailutils is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with GNU Mailutils.  If not, see <http://www.gnu.org/licenses/>. */

#include "imap4d.h"

jmp_buf child_jmp;
static int __critical_section;
static int __got_signal;

void
imap4d_enter_critical ()
{
  __critical_section = 1;
  if (__got_signal)
    __critical_section++;
}

void
imap4d_leave_critical ()
{
  if (__got_signal && __critical_section != 2)
    longjmp (child_jmp, __got_signal);
  __critical_section = 0;
}

RETSIGTYPE
imap4d_child_signal (int signo)
{
  imap4d_child_signal_setup (SIG_IGN);
  if (__critical_section)
    __got_signal = signo;
  else
    longjmp (child_jmp, signo);
}

Return to:

Send suggestions and report system problems to the System administrator.