1 | /* |
1 | /* |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
3 | * |
3 | * |
4 | * Copyright (©) 2005,2006,2007,2008,2009,2010,2011 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
4 | * Copyright (©) 2005,2006,2007,2008,2009,2010,2011,2012,2013,2014,2015,2016 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * Copyright (©) 2002 Mark Wedel & Crossfire Development Team |
5 | * Copyright (©) 2002 Mark Wedel & Crossfire Development Team |
6 | * Copyright (©) 1992 Frank Tore Johansen |
6 | * Copyright (©) 1992 Frank Tore Johansen |
7 | * |
7 | * |
8 | * Deliantra is free software: you can redistribute it and/or modify it under |
8 | * Deliantra is free software: you can redistribute it and/or modify it under |
9 | * the terms of the Affero GNU General Public License as published by the |
9 | * the terms of the Affero GNU General Public License as published by the |
10 | * Free Software Foundation, either version 3 of the License, or (at your |
10 | * Free Software Foundation, either version 3 of the License, or (at your |
11 | * option) any later version. |
11 | * option) any later version. |
12 | * |
12 | * |
13 | * This program is distributed in the hope that it will be useful, |
13 | * This program is distributed in the hope that it will be useful, |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | * GNU General Public License for more details. |
16 | * GNU General Public License for more details. |
17 | * |
17 | * |
18 | * You should have received a copy of the Affero GNU General Public License |
18 | * You should have received a copy of the Affero GNU General Public License |
19 | * and the GNU General Public License along with this program. If not, see |
19 | * and the GNU General Public License along with this program. If not, see |
20 | * <http://www.gnu.org/licenses/>. |
20 | * <http://www.gnu.org/licenses/>. |
21 | * |
21 | * |
22 | * The authors can be reached via e-mail to <support@deliantra.net> |
22 | * The authors can be reached via e-mail to <support@deliantra.net> |
23 | */ |
23 | */ |
24 | |
24 | |
25 | #include <global.h> |
25 | #include <global.h> |
26 | #include <material.h> |
26 | #include <material.h> |
… | |
… | |
343 | LOG (llevError, "SIGABRT received.\n"); |
343 | LOG (llevError, "SIGABRT received.\n"); |
344 | cleanup ("SIGABRT received", 1); |
344 | cleanup ("SIGABRT received", 1); |
345 | } |
345 | } |
346 | |
346 | |
347 | static void |
347 | static void |
|
|
348 | rec_sigquit (int i) |
|
|
349 | { |
|
|
350 | signal (SIGQUIT, SIG_IGN); |
|
|
351 | |
|
|
352 | LOG (llevInfo, "SIGQUIT received\n"); |
|
|
353 | cleanup ("SIGQUIT received", 1); |
|
|
354 | } |
|
|
355 | |
|
|
356 | static void |
348 | rec_sigsegv (int i) |
357 | rec_sigsegv (int i) |
349 | { |
358 | { |
350 | signal (SIGSEGV, SIG_DFL); |
359 | signal (SIGSEGV, SIG_DFL); |
351 | |
360 | |
352 | LOG (llevError, "SIGSEGV received.\n"); |
361 | LOG (llevError, "SIGSEGV received.\n"); |
353 | cleanup ("SIGSEGV received", 1); |
362 | cleanup ("SIGSEGV received", 1); |
354 | } |
363 | } |
355 | |
364 | |
356 | static void |
365 | static void |
357 | rec_sigquit (int i) |
|
|
358 | { |
|
|
359 | signal (SIGQUIT, SIG_IGN); |
|
|
360 | |
|
|
361 | LOG (llevInfo, "SIGQUIT received\n"); |
|
|
362 | cleanup ("SIGQUIT received", 1); |
|
|
363 | } |
|
|
364 | |
|
|
365 | static void |
|
|
366 | rec_sigbus (int i) |
366 | rec_sigbus (int i) |
367 | { |
367 | { |
368 | signal (SIGBUS, SIG_DFL); |
368 | signal (SIGBUS, SIG_DFL); |
369 | |
369 | |
370 | LOG (llevError, "SIGBUS received\n"); |
370 | LOG (llevError, "SIGBUS received\n"); |
371 | cleanup ("SIGBUS received", 1); |
371 | cleanup ("SIGBUS received", 1); |
|
|
372 | } |
|
|
373 | |
|
|
374 | static void |
|
|
375 | rec_sigfpe (int i) |
|
|
376 | { |
|
|
377 | signal (SIGFPE, SIG_DFL); |
|
|
378 | |
|
|
379 | LOG (llevError, "SIGFPE received.\n"); |
|
|
380 | cleanup ("SIGFPE received", 1); |
372 | } |
381 | } |
373 | |
382 | |
374 | void |
383 | void |
375 | reset_signals () |
384 | reset_signals () |
376 | { |
385 | { |
377 | signal (SIGABRT, SIG_DFL); |
386 | signal (SIGABRT, SIG_DFL); |
378 | signal (SIGQUIT, SIG_DFL); |
387 | signal (SIGQUIT, SIG_DFL); |
379 | signal (SIGSEGV, SIG_DFL); |
388 | signal (SIGSEGV, SIG_DFL); |
|
|
389 | #ifdef SIGBUS |
380 | signal (SIGBUS , SIG_DFL); |
390 | signal (SIGBUS , SIG_DFL); |
|
|
391 | #endif |
|
|
392 | signal (SIGFPE , SIG_DFL); |
381 | signal (SIGINT , SIG_DFL); |
393 | signal (SIGINT , SIG_DFL); |
382 | signal (SIGTERM, SIG_DFL); |
394 | signal (SIGTERM, SIG_DFL); |
383 | } |
395 | } |
384 | |
396 | |
385 | void |
397 | void |
… | |
… | |
401 | sa.sa_flags = SA_RESTART; |
413 | sa.sa_flags = SA_RESTART; |
402 | |
414 | |
403 | sa.sa_handler = SIG_IGN; sigaction (SIGPIPE, &sa, 0); |
415 | sa.sa_handler = SIG_IGN; sigaction (SIGPIPE, &sa, 0); |
404 | sa.sa_handler = rec_sigabrt; sigaction (SIGABRT, &sa, 0); |
416 | sa.sa_handler = rec_sigabrt; sigaction (SIGABRT, &sa, 0); |
405 | sa.sa_handler = rec_sigquit; sigaction (SIGQUIT, &sa, 0); |
417 | sa.sa_handler = rec_sigquit; sigaction (SIGQUIT, &sa, 0); |
|
|
418 | #ifdef SIGBUS |
406 | sa.sa_handler = rec_sigbus; sigaction (SIGBUS, &sa, 0); |
419 | sa.sa_handler = rec_sigbus; sigaction (SIGBUS, &sa, 0); |
|
|
420 | #endif |
|
|
421 | sa.sa_handler = rec_sigfpe; sigaction (SIGFPE, &sa, 0); |
407 | |
422 | |
408 | sa.sa_flags |= SA_ONSTACK; |
423 | sa.sa_flags |= SA_ONSTACK; |
409 | sa.sa_handler = rec_sigsegv; sigaction (SIGSEGV, &sa, 0); |
424 | sa.sa_handler = rec_sigsegv; sigaction (SIGSEGV, &sa, 0); |
410 | } |
425 | } |
411 | |
426 | |