[xiph-commits] r12541 - trunk/ezstream/src
moritz at svn.xiph.org
moritz at svn.xiph.org
Sat Feb 24 14:01:37 PST 2007
Author: moritz
Date: 2007-02-24 14:01:35 -0800 (Sat, 24 Feb 2007)
New Revision: 12541
Added:
trunk/ezstream/src/ezsignals.h
Log:
Commit header with three macros that help with signal handling. Will be actually
used later. Now, all new files are in.
Added: trunk/ezstream/src/ezsignals.h
===================================================================
--- trunk/ezstream/src/ezsignals.h 2007-02-24 21:59:07 UTC (rev 12540)
+++ trunk/ezstream/src/ezsignals.h 2007-02-24 22:01:35 UTC (rev 12541)
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2007 Moritz Grimm <gtgbr at 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__ */
More information about the commits
mailing list