summaryrefslogtreecommitdiff
path: root/apps/plugins/pdbox/PDa/src/s_watchdog.c
diff options
context:
space:
mode:
authorPeter D'Hoye <peter.dhoye@gmail.com>2009-05-22 21:58:48 +0000
committerPeter D'Hoye <peter.dhoye@gmail.com>2009-05-22 21:58:48 +0000
commit513389b4c1bc8afe4b2dc9947c534bfeb105e3da (patch)
tree10e673b35651ac567fed2eda0c679c7ade64cbc6 /apps/plugins/pdbox/PDa/src/s_watchdog.c
parent95fa7f6a2ef466444fbe3fe87efc6d5db6b77b36 (diff)
downloadrockbox-513389b4c1bc8afe4b2dc9947c534bfeb105e3da.tar.gz
rockbox-513389b4c1bc8afe4b2dc9947c534bfeb105e3da.zip
Add FS #10214. Initial commit of the original PDa code for the GSoC Pure Data plugin project of Wincent Balin. Stripped some non-sourcefiles and added a rockbox readme that needs a bit more info from Wincent. Is added to CATEGORIES and viewers, but not yet to SUBDIRS (ie doesn't build yet)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21044 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/pdbox/PDa/src/s_watchdog.c')
-rw-r--r--apps/plugins/pdbox/PDa/src/s_watchdog.c94
1 files changed, 94 insertions, 0 deletions
diff --git a/apps/plugins/pdbox/PDa/src/s_watchdog.c b/apps/plugins/pdbox/PDa/src/s_watchdog.c
new file mode 100644
index 0000000000..48309c16c4
--- /dev/null
+++ b/apps/plugins/pdbox/PDa/src/s_watchdog.c
@@ -0,0 +1,94 @@
1/* Copyright (c) 1997-2000 Miller Puckette.
2* For information on usage and redistribution, and for a DISCLAIMER OF ALL
3* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
4
5/* This file is compiled into the separate program, "pd-watchdog," which
6tries to prevent Pd from locking up the processor if it's at realtime
7priority. Linux only. Invoked from s_inter.c. */
8
9#include <sys/time.h>
10#include <sys/types.h>
11#include <unistd.h>
12#include <signal.h>
13#include <stdio.h>
14
15int main(int argc, char **argv)
16{
17 int happy = 1;
18 while (1)
19 {
20 struct timeval timout;
21 fd_set readset;
22 if (happy)
23 {
24 timout.tv_sec = 5;
25 timout.tv_usec = 0;
26 }
27 else
28 {
29 timout.tv_sec = 2;
30 timout.tv_usec = 0;
31 }
32 FD_ZERO(&readset);
33 FD_SET(0, &readset);
34 select(1, &readset, 0, 0, &timout);
35 if (FD_ISSET(0, &readset))
36 {
37 char buf[100];
38 happy = 1;
39 if (read(0, &buf, 100) <= 0)
40 return (0);
41 else continue;
42 }
43 happy = 0;
44 kill(getppid(), SIGHUP);
45 fprintf(stderr, "watchdog: signaling pd...\n");
46 }
47}
48/* Copyright (c) 1997-2000 Miller Puckette.
49* For information on usage and redistribution, and for a DISCLAIMER OF ALL
50* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
51
52/* This file is compiled into the separate program, "pd-watchdog," which
53tries to prevent Pd from locking up the processor if it's at realtime
54priority. Linux only. Invoked from s_inter.c. */
55
56#include <sys/time.h>
57#include <sys/types.h>
58#include <unistd.h>
59#include <signal.h>
60#include <stdio.h>
61
62int main(int argc, char **argv)
63{
64 int happy = 1;
65 while (1)
66 {
67 struct timeval timout;
68 fd_set readset;
69 if (happy)
70 {
71 timout.tv_sec = 5;
72 timout.tv_usec = 0;
73 }
74 else
75 {
76 timout.tv_sec = 2;
77 timout.tv_usec = 0;
78 }
79 FD_ZERO(&readset);
80 FD_SET(0, &readset);
81 select(1, &readset, 0, 0, &timout);
82 if (FD_ISSET(0, &readset))
83 {
84 char buf[100];
85 happy = 1;
86 if (read(0, &buf, 100) <= 0)
87 return (0);
88 else continue;
89 }
90 happy = 0;
91 kill(getppid(), SIGHUP);
92 fprintf(stderr, "watchdog: signaling pd...\n");
93 }
94}