aboutsummaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2010-06-29 15:39:42 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2010-06-29 15:39:42 +0000
commitb5b6ae8b070e20732ae2f6afdfc248b372242462 (patch)
treecaf24ce35018caae3c5814d14309bf90387de590 /contrib
parent75ea0957000cec727be72b3bb9a4e70f1a63a114 (diff)
downloadgnunet-b5b6ae8b070e20732ae2f6afdfc248b372242462.tar.gz
gnunet-b5b6ae8b070e20732ae2f6afdfc248b372242462.zip
Diffstat (limited to 'contrib')
-rw-r--r--contrib/Makefile.am6
-rw-r--r--contrib/timeout_watchdog.c26
2 files changed, 19 insertions, 13 deletions
diff --git a/contrib/Makefile.am b/contrib/Makefile.am
index f8e0d2f49..43348b309 100644
--- a/contrib/Makefile.am
+++ b/contrib/Makefile.am
@@ -1,3 +1,9 @@
1noinst_PROGRAMS = \
2 timeout_watchdog
3
4timeout_watchdog_SOURCES = \
5 timeout_watchdog.c
6
1dist_pkgdata_DATA = \ 7dist_pkgdata_DATA = \
2 gnunet-logo-color.png \ 8 gnunet-logo-color.png \
3 defaults.conf 9 defaults.conf
diff --git a/contrib/timeout_watchdog.c b/contrib/timeout_watchdog.c
index 82bf11b0f..27b46f2b0 100644
--- a/contrib/timeout_watchdog.c
+++ b/contrib/timeout_watchdog.c
@@ -24,13 +24,13 @@
24 * @author Matthias Wachs 24 * @author Matthias Wachs
25 */ 25 */
26 26
27#include "signal.h" 27#include <sys/types.h>
28#include "stdio.h" 28#include <signal.h>
29#include "stdlib.h" 29#include <stdio.h>
30#include <stdlib.h>
30#include <unistd.h> 31#include <unistd.h>
31#include <wait.h> 32#include <wait.h>
32 33
33static int child_died;
34static pid_t child; 34static pid_t child;
35 35
36static void sigchld_handler(int val) 36static void sigchld_handler(int val)
@@ -55,15 +55,13 @@ static void sigchld_handler(int val)
55static void sigint_handler(int val) 55static void sigint_handler(int val)
56{ 56{
57 kill(0, val); 57 kill(0, val);
58 exit(1); 58 exit(val);
59} 59}
60 60
61
62int main(int argc, char *argv[]) 61int main(int argc, char *argv[])
63{ 62{
64int timeout = 0; 63int timeout = 0;
65int remain = 0; 64pid_t gpid =0;
66int ret = 0;
67 65
68if (argc < 3) 66if (argc < 3)
69{ 67{
@@ -76,21 +74,22 @@ timeout = atoi(argv[1]);
76if (timeout == 0) 74if (timeout == 0)
77 timeout = 600; 75 timeout = 600;
78 76
77/* with getpgid() it does not compile, but getpgrp is the BSD version and working */
78gpid = getpgrp();
79 79
80char ** arguments = &argv[3];
81
82pid_t gpid = getpgid(0);
83signal(SIGCHLD, sigchld_handler); 80signal(SIGCHLD, sigchld_handler);
84signal(SIGABRT, sigint_handler); 81signal(SIGABRT, sigint_handler);
85signal(SIGKILL, sigint_handler); 82signal(SIGFPE, sigint_handler);
86signal(SIGILL, sigint_handler); 83signal(SIGILL, sigint_handler);
87signal(SIGSEGV, sigint_handler);
88signal(SIGINT, sigint_handler); 84signal(SIGINT, sigint_handler);
85signal(SIGSEGV, sigint_handler);
89signal(SIGTERM, sigint_handler); 86signal(SIGTERM, sigint_handler);
90 87
91child = fork(); 88child = fork();
92if (child==0) 89if (child==0)
93{ 90{
91 /* int setpgrp(pid_t pid, pid_t pgid); is not working on this machine*/
92 //setpgrp (0, pid_t gpid);
94 setpgid(0,gpid); 93 setpgid(0,gpid);
95 execvp(argv[2],&argv[2]); 94 execvp(argv[2],&argv[2]);
96 exit(1); 95 exit(1);
@@ -101,6 +100,7 @@ if (child > 0)
101 kill(0,SIGABRT); 100 kill(0,SIGABRT);
102 exit(1); 101 exit(1);
103} 102}
103exit(1);
104} 104}
105 105
106/* end of timeout_watchdog.c */ 106/* end of timeout_watchdog.c */