diff --git a/Readme.md b/Readme.md index 627a408d256c8c440124799f5e78562a3c545753..15cda65320d8a119851c0dc8808c2dd7ae51b335 100644 --- a/Readme.md +++ b/Readme.md @@ -207,16 +207,16 @@ int main() { if( sigaction(SIGCHLD, &handleSIGCHLD, NULL) != 0 ) die("Could not set sigaction"); //mask sigchld - sigset_t newMask_Itr; - sigset_t oldMask_Itr; - sigemptyset(&newMask_Itr); - sigaddset(&newMask_Itr, SIGCHLD); - if (sigprocmask(SIG_BLOCK, &newMask_Itr, &oldMask_Itr) == -1) die("sigprocmask"); + sigset_t newMask; + sigset_t oldMask; + sigemptyset(&newMask); + sigaddset(&newMask, SIGCHLD); + if (sigprocmask(SIG_BLOCK, &newMask, &oldMask) == -1) die("sigprocmask"); //do critical stuff //alte signal mask wiederherstellen - if (sigprocmask(SIG_SETMASK, &oldMask_Itr, NULL) == -1) die("sigprocmask"); + if (sigprocmask(SIG_SETMASK, &oldMask, NULL) == -1) die("sigprocmask"); pid_t pid = fork(); if(pid < 0) die("fork"); @@ -227,9 +227,9 @@ int main() { //passives warten pcount = 1; - if (sigprocmask(SIG_BLOCK, &newMask_Itr, &oldMask_Itr) == -1) die("sigprocmask"); + if (sigprocmask(SIG_BLOCK, &newMask, &oldMask) == -1) die("sigprocmask"); while (pcount > 0) { - sigsuspend(&oldMask_Itr); + sigsuspend(&oldMask); } } diff --git a/Zettel.html b/Zettel.html index 8714e1a26c66a63b6c702e8c767a02b67c5c6aa9..bd9949b871f59212f44373b2abc7bbd90cef0a6c 100644 --- a/Zettel.html +++ b/Zettel.html @@ -195,16 +195,16 @@ accept</p> <span class="hljs-keyword">if</span>( sigaction(SIGCHLD, &handleSIGCHLD, <span class="hljs-literal">NULL</span>) != <span class="hljs-number">0</span> ) die(<span class="hljs-string">"Could not set sigaction"</span>); <span class="hljs-comment">//mask sigchld</span> - <span class="hljs-keyword">sigset_t</span> newMask_Itr; - <span class="hljs-keyword">sigset_t</span> oldMask_Itr; - sigemptyset(&newMask_Itr); - sigaddset(&newMask_Itr, SIGCHLD); - <span class="hljs-keyword">if</span> (sigprocmask(SIG_BLOCK, &newMask_Itr, &oldMask_Itr) == <span class="hljs-number">-1</span>) die(<span class="hljs-string">"sigprocmask"</span>); + <span class="hljs-keyword">sigset_t</span> newMask; + <span class="hljs-keyword">sigset_t</span> oldMask; + sigemptyset(&newMask); + sigaddset(&newMask, SIGCHLD); + <span class="hljs-keyword">if</span> (sigprocmask(SIG_BLOCK, &newMask, &oldMask) == <span class="hljs-number">-1</span>) die(<span class="hljs-string">"sigprocmask"</span>); <span class="hljs-comment">//do critical stuff</span> <span class="hljs-comment">//alte signal mask wiederherstellen</span> - <span class="hljs-keyword">if</span> (sigprocmask(SIG_SETMASK, &oldMask_Itr, <span class="hljs-literal">NULL</span>) == <span class="hljs-number">-1</span>) die(<span class="hljs-string">"sigprocmask"</span>); + <span class="hljs-keyword">if</span> (sigprocmask(SIG_SETMASK, &oldMask, <span class="hljs-literal">NULL</span>) == <span class="hljs-number">-1</span>) die(<span class="hljs-string">"sigprocmask"</span>); <span class="hljs-keyword">pid_t</span> pid = fork(); <span class="hljs-keyword">if</span>(pid < <span class="hljs-number">0</span>) die(<span class="hljs-string">"fork"</span>); @@ -215,9 +215,9 @@ accept</p> <span class="hljs-comment">//passives warten</span> pcount = <span class="hljs-number">1</span>; - <span class="hljs-keyword">if</span> (sigprocmask(SIG_BLOCK, &newMask_Itr, &oldMask_Itr) == <span class="hljs-number">-1</span>) die(<span class="hljs-string">"sigprocmask"</span>); + <span class="hljs-keyword">if</span> (sigprocmask(SIG_BLOCK, &newMask, &oldMask) == <span class="hljs-number">-1</span>) die(<span class="hljs-string">"sigprocmask"</span>); <span class="hljs-keyword">while</span> (pcount > <span class="hljs-number">0</span>) { - sigsuspend(&oldMask_Itr); + sigsuspend(&oldMask); } } diff --git a/signal.c b/signal.c index 1b5706062e1bb1b1c219a0191e510cb35c34935c..7ef89f92001f9f9a0aede04ea2b5549a7b8f5685 100644 --- a/signal.c +++ b/signal.c @@ -16,16 +16,16 @@ int main() { if( sigaction(SIGCHLD, &handleSIGCHLD, NULL) != 0 ) die("Could not set sigaction"); //mask sigchld - sigset_t newMask_Itr; - sigset_t oldMask_Itr; - sigemptyset(&newMask_Itr); - sigaddset(&newMask_Itr, SIGCHLD); - if (sigprocmask(SIG_BLOCK, &newMask_Itr, &oldMask_Itr) == -1) die("sigprocmask"); + sigset_t newMask; + sigset_t oldMask; + sigemptyset(&newMask); + sigaddset(&newMask, SIGCHLD); + if (sigprocmask(SIG_BLOCK, &newMask, &oldMask) == -1) die("sigprocmask"); //do critical stuff //alte signal mask wiederherstellen - if (sigprocmask(SIG_SETMASK, &oldMask_Itr, NULL) == -1) die("sigprocmask"); + if (sigprocmask(SIG_SETMASK, &oldMask, NULL) == -1) die("sigprocmask"); pid_t pid = fork(); if(pid < 0) die("fork"); @@ -36,9 +36,9 @@ int main() { //passives warten pcount = 1; - if (sigprocmask(SIG_BLOCK, &newMask_Itr, &oldMask_Itr) == -1) die("sigprocmask"); + if (sigprocmask(SIG_BLOCK, &newMask, &oldMask) == -1) die("sigprocmask"); while (pcount > 0) { - sigsuspend(&oldMask_Itr); + sigsuspend(&oldMask); } }