Add RVA2 tag support to MPD
[mpd-mk/avuton.git] / src / signal_check.c
blob5cf16e987c82abcd2de733e7ea7b9ae71ff4fea8
1 /* the Music Player Daemon (MPD)
2 * Copyright (C) 2003-2007 by Warren Dukes (warren.dukes@gmail.com)
3 * (c)2004 by mackstann
4 * This project's homepage is: http://www.musicpd.org
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 #include "signal_check.h"
21 #include "os_compat.h"
23 static volatile sig_atomic_t caught_signals[NSIG];
25 static void mpd_signal_handler(int sig)
27 caught_signals[sig] = 1;
30 static void set_signal_handler(int sig, void (*handler) (int))
32 struct sigaction act;
33 act.sa_flags = 0;
34 sigemptyset(&act.sa_mask);
35 act.sa_handler = handler;
36 while (sigaction(sig, &act, NULL) && errno == EINTR) ;
39 void signal_handle(int sig)
41 set_signal_handler(sig, mpd_signal_handler);
44 void signal_unhandle(int sig)
46 signal_clear(sig);
47 set_signal_handler(sig, SIG_DFL);
50 int signal_is_pending(int sig)
52 return caught_signals[sig];
55 void signal_clear(int sig)
57 caught_signals[sig] = 0;