1
0
mirror of https://gitlab.xiph.org/xiph/ezstream.git synced 2024-12-04 14:46:31 -05:00

Commit header with three macros that help with signal handling. Will be actually

used later. Now, all new files are in.


git-svn-id: https://svn.xiph.org/trunk/ezstream@12541 0101bb08-14d6-0310-b084-bc0e0c8e3800
This commit is contained in:
moritz 2007-02-24 22:01:35 +00:00
parent 1fca228230
commit 5d3fc1ddda

58
src/ezsignals.h Normal file
View File

@ -0,0 +1,58 @@
/*
* Copyright (c) 2007 Moritz Grimm <gtgbr@gmx.net>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* Macros to install, suspend and restore signals */
#ifndef __EZSIGNALS_H__
#define __EZSIGNALS_H__
#define SIGS_INSTALL(a, b) do { \
unsigned int i; \
for (i = 0; i < sizeof(a) / sizeof(int); i++) { \
if (sigaction((a)[i], (b), NULL) == -1) { \
printf("%s: sigaction(): %s\n", \
__progname, strerror(errno)); \
return (1); \
} \
} \
} while (0);
#define SIGS_SUSPEND(a, b) do { \
unsigned int i; \
sigset_t sigset; \
sigemptyset(&sigset); \
for (i = 0; i < sizeof(a) / sizeof(int); i++) { \
if (sigaddset(&sigset, (a)[i]) == -1) \
printf("%s: sigaddset(): %s\n", \
__progname, strerror(errno)); \
exit(1); \
} \
if (sigprocmask(SIG_BLOCK, &sigset, (b)) == -1) { \
printf("%s: sigprocmask(): %s\n", __progname, \
strerror(errno)); \
exit(1); \
} \
} while (0);
#define SIGS_RESTORE(a) do { \
if (sigprocmask(SIG_SETMASK, (a), NULL) == -1) { \
printf("%s: sigprocmask(): %s\n", __progname, \
strerror(errno)); \
exit(1); \
} \
} while (0);
#endif /* __EZSIGNALS_H__ */