1 /* Break.c implements an interrupt handler for SIGINT.
3 Copyright (C) 2004-2022 Free Software Foundation, Inc.
4 Contributed by Gaius Mulley <gaius.mulley@southwales.ac.uk>.
6 This file is part of GNU Modula-2.
8 GNU Modula-2 is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3, or (at your option)
13 GNU Modula-2 is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
18 Under Section 7 of GPL version 3, you are granted additional
19 permissions described in the GCC Runtime Library Exception, version
20 3.1, as published by the Free Software Foundation.
22 You should have received a copy of the GNU General Public License and
23 a copy of the GCC Runtime Library Exception along with this program;
24 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
25 <http://www.gnu.org/licenses/>. */
29 #if defined(HAVE_STDIO_H)
33 #if defined(HAVE_STDARG_H)
37 #if defined(HAVE_STDLIB_H)
41 #if defined(HAVE_MALLOC_H)
45 typedef void (*PROC
) (void);
47 #if defined(HAVE_SIGNAL_H)
56 static struct plist
*head
= NULL
;
58 /* localHandler - dismisses the parameter, p, and invokes the GNU
68 /* EnableBreak - enable the current break handler. */
71 Break_EnableBreak (void)
73 signal (SIGINT
, localHandler
);
76 /* DisableBreak - disable the current break handler (and all
77 installed handlers). */
80 Break_DisableBreak (void)
82 signal (SIGINT
, SIG_IGN
);
85 /* InstallBreak - installs a procedure, p, to be invoked when a
86 ctrl-c is caught. Any number of these procedures may be stacked.
87 Only the top procedure is run when ctrl-c is caught. */
90 Break_InstallBreak (PROC p
)
92 struct plist
*q
= (struct plist
*)malloc (sizeof (struct plist
));
96 perror ("out of memory error in module Break");
104 /* UnInstallBreak - pops the break handler stack. */
107 Break_UnInstallBreak (void)
109 struct plist
*q
= head
;
119 Break_EnableBreak (void)
123 Break_DisableBreak (void)
127 Break_InstallBreak (PROC
*p
)
131 Break_UnInstallBreak (void)