1 /* GNU Mailutils -- a suite of utilities for electronic mail 2 Copyright (C) 1999-2021 Free Software Foundation, Inc. 3 4 GNU Mailutils is free software; you can redistribute it and/or modify 5 it under the terms of the GNU General Public License as published by 6 the Free Software Foundation; either version 3, or (at your option) 7 any later version. 8 9 GNU Mailutils is distributed in the hope that it will be useful, 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 GNU General Public License for more details. 13 14 You should have received a copy of the GNU General Public License 15 along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. */ 16 17 #include "imap4d.h" 18 19 jmp_buf child_jmp; 20 static int __critical_section; 21 static int __got_signal; 22 23 void imap4d_enter_critical()24imap4d_enter_critical () 25 { 26 __critical_section = 1; 27 if (__got_signal) 28 __critical_section++; 29 } 30 31 void imap4d_leave_critical()32imap4d_leave_critical () 33 { 34 if (__got_signal && __critical_section != 2) 35 longjmp (child_jmp, __got_signal); 36 __critical_section = 0; 37 } 38 39 RETSIGTYPE imap4d_child_signal(int signo)40imap4d_child_signal (int signo) 41 { 42 imap4d_child_signal_setup (SIG_IGN); 43 if (__critical_section) 44 __got_signal = signo; 45 else 46 longjmp (child_jmp, signo); 47 } 48