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.10 PTH_1_0b7:1.10 PTH_1_0b6:1.10 PTH_1_0b5:1.10 PTH_1_0b4:1.9 PTH_1_0b3:1.7 PTH_1_0b2:1.7 PTH_1_0b1:1.6 PTH_0_9_21:1.5 PTH_0_9_20:1.5 PTH_0_9_19:1.4 PTH_0_9_18:1.4 PTH_0_9_17:1.2 PTH_0_9_16:1.2 PTH_0_9_15:1.2; locks; strict; comment @ * @; 1.24 date 2007.01.01.18.23.53; author rse; state Exp; branches; next 1.23; commitid 9DhdiirNzQPBIP0s; 1.23 date 2006.06.08.17.54.54; author rse; state Exp; branches; next 1.22; commitid x8N3mLVdQgkbdeAr; 1.22 date 2004.12.31.19.34.45; author rse; state Exp; branches; next 1.21; 1.21 date 2004.07.13.10.50.49; author rse; state Exp; branches; next 1.20; 1.20 date 2003.01.01.15.49.12; author rse; state Exp; branches; next 1.19; 1.19 date 2002.01.27.11.03.41; author rse; state Exp; branches; next 1.18; 1.18 date 2001.03.24.14.51.05; author rse; state Exp; branches; next 1.17; 1.17 date 2000.01.09.16.45.02; author rse; state Exp; branches; next 1.16; 1.16 date 99.12.30.21.59.02; author rse; state Exp; branches; next 1.15; 1.15 date 99.11.09.08.11.33; author rse; state Exp; branches; next 1.14; 1.14 date 99.11.01.10.27.21; author rse; state Exp; branches; next 1.13; 1.13 date 99.10.31.11.46.14; author rse; state Exp; branches 1.13.2.1; next 1.12; 1.12 date 99.09.17.08.01.56; author rse; state Exp; branches; next 1.11; 1.11 date 99.08.17.08.08.36; author rse; state Exp; branches; next 1.10; 1.10 date 99.07.10.14.21.18; author rse; state Exp; branches; next 1.9; 1.9 date 99.07.08.10.34.02; author rse; state Exp; branches; next 1.8; 1.8 date 99.07.08.10.19.12; author rse; state Exp; branches; next 1.7; 1.7 date 99.07.04.12.05.36; author rse; state Exp; branches; next 1.6; 1.6 date 99.06.27.15.38.04; author rse; state Exp; branches; next 1.5; 1.5 date 99.06.24.10.55.32; author rse; state Exp; branches; next 1.4; 1.4 date 99.06.20.09.58.57; author rse; state Exp; branches; next 1.3; 1.3 date 99.06.20.09.52.02; author rse; state Exp; branches; next 1.2; 1.2 date 99.06.04.10.47.42; author rse; state Exp; branches; next 1.1; 1.1 date 99.06.02.14.38.45; author rse; state Exp; branches; next ; 1.13.2.1 date 99.11.01.10.25.03; author rse; state Exp; branches; next 1.13.2.2; 1.13.2.2 date 2000.02.04.22.07.18; author rse; state Exp; branches; next ; desc @@ 1.24 log @Adjusted all copyright messages for new year 2007. @ text @/* ** GNU Pth - The GNU Portable Threads ** Copyright (c) 1999-2007 Ralf S. Engelschall ** ** This file is part of GNU Pth, a non-preemptive thread scheduling ** library which can be found at http://www.gnu.org/software/pth/. ** ** This library is free software; you can redistribute it and/or ** modify it under the terms of the GNU Lesser General Public ** License as published by the Free Software Foundation; either ** version 2.1 of the License, or (at your option) any later version. ** ** This library is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ** Lesser General Public License for more details. ** ** You should have received a copy of the GNU Lesser General Public ** License along with this library; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 ** USA, or contact Ralf S. Engelschall . ** ** test_sig.c: Pth test program (signal handling) */ #include #include #include #include #include #include #include "pth.h" static pth_t child1; static pth_t child2; static void *inthandler(void *_arg) { sigset_t sigs; int sig; int n; fprintf(stderr, "inthandler: enter\n"); /* unblock interrupt signal only here */ sigemptyset(&sigs); sigaddset(&sigs, SIGINT); pth_sigmask(SIG_UNBLOCK, &sigs, NULL); /* but the user has to hit CTRL-C three times */ for (n = 0; n < 3; n++) { pth_sigwait(&sigs, &sig); fprintf(stderr, "inthandler: SIGINT received (#%d)\n", n); } fprintf(stderr, "inthandler: cancelling child1 and child2\n"); pth_cancel(child1); pth_cancel(child2); fprintf(stderr, "inthandler: leave\n"); return NULL; } static void child_cleanup(void *arg) { fprintf(stderr, "%s: running cleanup\n", (char *)arg); return; } static void *child(void *_arg) { sigset_t sigs; char *name = (char *)_arg; int i; fprintf(stderr, "%s: enter\n", name); /* establish cleanup handler */ pth_cleanup_push(child_cleanup, name); /* block different types of signals */ pth_sigmask(SIG_SETMASK, NULL, &sigs); sigaddset(&sigs, SIGINT); if (strcmp(name, "child1") == 0) { sigaddset(&sigs, SIGUSR1); sigdelset(&sigs, SIGUSR2); } else { sigdelset(&sigs, SIGUSR1); sigaddset(&sigs, SIGUSR2); } pth_sigmask(SIG_SETMASK, &sigs, NULL); /* do a little bit of processing and show signal states */ for (i = 0; i < 10; i++) { pth_sigmask(SIG_SETMASK, NULL, &sigs); fprintf(stderr, "%s: SIGUSR1: %s\n", name, sigismember(&sigs, SIGUSR1) ? "blocked" : "unblocked"); fprintf(stderr, "%s: SIGUSR2: %s\n", name, sigismember(&sigs, SIGUSR2) ? "blocked" : "unblocked"); fprintf(stderr, "%s: leave to scheduler\n", name); pth_sleep(1); fprintf(stderr, "%s: reentered from scheduler\n", name); } fprintf(stderr, "%s: leave\n", name); return NULL; } int main(int argc, char *argv[]) { pth_attr_t attr; sigset_t sigs; pth_init(); fprintf(stderr, "This is TEST_SIG, a Pth test using signals.\n"); fprintf(stderr, "\n"); fprintf(stderr, "Hit CTRL-C three times to stop this test.\n"); fprintf(stderr, "But only after all threads were terminated.\n"); fprintf(stderr, "\n"); fprintf(stderr, "main: init\n"); /* block signals */ pth_sigmask(SIG_SETMASK, NULL, &sigs); sigaddset(&sigs, SIGUSR1); sigaddset(&sigs, SIGUSR2); sigaddset(&sigs, SIGINT); pth_sigmask(SIG_SETMASK, &sigs, NULL); /* spawn childs */ attr = pth_attr_new(); pth_attr_set(attr, PTH_ATTR_NAME, "child1"); child1 = pth_spawn(attr, child, (void *)"child1"); pth_attr_set(attr, PTH_ATTR_NAME, "child2"); child2 = pth_spawn(attr, child, (void *)"child2"); pth_attr_set(attr, PTH_ATTR_NAME, "inthandler"); pth_spawn(attr, inthandler, (void *)"inthandler"); pth_attr_destroy(attr); /* wait until childs are finished */ while (pth_join(NULL, NULL)); fprintf(stderr, "main: exit\n"); pth_kill(); return 0; } @ 1.23 log @Adjusted all copyright messages for new year 2006 @ text @d3 1 a3 1 ** Copyright (c) 1999-2006 Ralf S. Engelschall @ 1.22 log @Adjusted all copyright messages for new year 2005. @ text @d3 1 a3 1 ** Copyright (c) 1999-2005 Ralf S. Engelschall @ 1.21 log @Adjusted all copyright messages for new year 2004. @ text @d3 1 a3 1 ** Copyright (c) 1999-2004 Ralf S. Engelschall @ 1.20 log @Adjusted all copyright messages for new year 2003. @ text @d3 1 a3 1 ** Copyright (c) 1999-2003 Ralf S. Engelschall @ 1.19 log @bump copyright year @ text @d3 1 a3 1 ** Copyright (c) 1999-2002 Ralf S. Engelschall @ 1.18 log @*** empty log message *** @ text @d3 1 a3 1 ** Copyright (c) 1999-2001 Ralf S. Engelschall @ 1.17 log @*** empty log message *** @ text @d3 1 a3 1 ** Copyright (c) 1999-2000 Ralf S. Engelschall @ 1.16 log @*** empty log message *** @ text @d56 2 d67 1 a67 1 fprintf(stderr, "Child %s cleanup\n", (char *)arg); d144 1 a144 1 while (pth_join(NULL, NULL) == 0) ; @ 1.15 log @*** empty log message *** @ text @d3 1 a3 1 ** Copyright (c) 1999 Ralf S. Engelschall @ 1.14 log @*** empty log message *** @ text @d80 1 a80 1 /* block different types of signals */ d96 1 a96 1 fprintf(stderr, "%s: SIGUSR1: %s\n", name, d98 1 a98 1 fprintf(stderr, "%s: SIGUSR2: %s\n", name, d109 1 a109 1 int main(int argc, char *argv[]) d113 1 a113 1 @ 1.13 log @*** empty log message *** @ text @d2 1 a2 2 ** test_sig.c -- Pth test program (signal handling) ** d22 2 @ 1.13.2.1 log @*** empty log message *** @ text @d2 2 a3 1 ** GNU Pth - The GNU Portable Threads a22 2 ** ** test_sig.c: Pth test program (signal handling) @ 1.13.2.2 log @*** empty log message *** @ text @a55 2 fprintf(stderr, "inthandler: cancelling child1 and child2\n"); d65 1 a65 1 fprintf(stderr, "%s: running cleanup\n", (char *)arg); d142 1 a142 1 while (pth_join(NULL, NULL)); @ 1.12 log @*** empty log message *** @ text @d12 1 a12 1 ** version 2 of the License, or (at your option) any later version. @ 1.11 log @*** empty log message *** @ text @d10 1 a10 1 ** modify it under the terms of the GNU Library General Public d17 1 a17 1 ** Library General Public License for more details. d19 1 a19 1 ** You should have received a copy of the GNU Library General Public @ 1.10 log @*** empty log message *** @ text @d133 1 a133 1 child1 = pth_spawn(attr, child, "child1"); d135 1 a135 1 child2 = pth_spawn(attr, child, "child2"); d137 1 a137 1 pth_spawn(attr, inthandler, "inthandler"); @ 1.9 log @*** empty log message *** @ text @d112 2 a121 1 pth_init(); @ 1.8 log @*** empty log message *** @ text @d2 1 a2 1 ** test_sig.c -- PTH test program (signal handling) d113 1 a113 1 fprintf(stderr, "This is TEST_SIG, a PTH test using signals.\n"); @ 1.7 log @*** empty log message *** @ text @d6 2 a7 2 ** This file is part of PTH, a non-preemptive thread scheduling library ** which can be found at http://www.gnu.org/software/pth/. @ 1.6 log @*** empty log message *** @ text @d7 1 a7 1 ** which can be found at http://www.engelschall.com/sw/pth/. @ 1.5 log @*** empty log message *** @ text @d130 8 a137 6 attr = pth_attr("child1", PTH_PRIO_STD, PTH_FLAG_NONE, PTH_CANCEL_DEFAULT, 32*1024, NULL); child1 = pth_spawn(&attr, child, "child1"); attr = pth_attr("child2", PTH_PRIO_STD, PTH_FLAG_NONE, PTH_CANCEL_DEFAULT, 32*1024, NULL); child2 = pth_spawn(&attr, child, "child2"); attr = pth_attr("inthandler", PTH_PRIO_STD, PTH_FLAG_NONE, PTH_CANCEL_DEFAULT, 32*1024, NULL); pth_spawn(&attr, inthandler, "inthandler"); @ 1.4 log @*** empty log message *** @ text @d48 1 a48 1 sigprocmask(SIG_UNBLOCK, &sigs, NULL); d80 1 a80 1 sigprocmask(SIG_SETMASK, NULL, &sigs); d90 1 a90 1 sigprocmask(SIG_SETMASK, &sigs, NULL); d94 1 a94 1 sigprocmask(SIG_SETMASK, NULL, &sigs); d123 1 a123 1 sigprocmask(SIG_SETMASK, NULL, &sigs); d127 1 a127 1 sigprocmask(SIG_SETMASK, &sigs, NULL); @ 1.3 log @*** empty log message *** @ text @d34 3 d55 2 d62 6 d76 3 d131 1 a131 1 pth_spawn(&attr, child, "child1"); d133 1 a133 1 pth_spawn(&attr, child, "child2"); @ 1.2 log @*** empty log message *** @ text @d116 1 a116 1 attr = pth_attr("child1", PTH_PRIO_STD, PTH_FLAG_NONE, 32*1024, NULL); d118 1 a118 1 attr = pth_attr("child2", PTH_PRIO_STD, PTH_FLAG_NONE, 32*1024, NULL); d120 1 a120 1 attr = pth_attr("inthandler", PTH_PRIO_STD, PTH_FLAG_NONE, 32*1024, NULL); @ 1.1 log @*** empty log message *** @ text @d34 23 d64 2 d67 1 d78 1 d86 1 a86 1 pth_yield(); d89 1 d99 7 d108 1 d110 3 a112 2 sigdelset(&sigs, SIGUSR1); sigdelset(&sigs, SIGUSR2); d115 1 d120 7 a126 1 while (pth_join(NULL, NULL)) ; @