1
From a0695829bdc0e76ef35dd6c3ce00141b6e7863af Mon Sep 17 00:00:00 2001
1
From afd823b21c544eb4764d9e38f2f15e5a4f50ab7a Mon Sep 17 00:00:00 2001
2
2
From: David Henningsson <david.henningsson@canonical.com>
3
3
Date: Wed, 17 Apr 2013 16:07:32 +0200
4
4
Subject: [PATCH] inotify-wrapper: Quit daemon if pid file is removed
16
16
Signed-off-by: David Henningsson <david.henningsson@canonical.com>
18
18
src/Makefile.am | 1 +
19
src/daemon/main.c | 20 ++++++++-
20
src/pulsecore/inotify-wrapper.c | 93 +++++++++++++++++++++++++++++++++++++++
21
src/pulsecore/inotify-wrapper.h | 13 ++++++
22
src/pulsecore/pid.c | 5 +++
19
src/daemon/main.c | 20 +++++++-
20
src/pulsecore/inotify-wrapper.c | 103 +++++++++++++++++++++++++++++++++++++++
21
src/pulsecore/inotify-wrapper.h | 13 +++++
22
src/pulsecore/pid.c | 5 ++
23
23
src/pulsecore/pid.h | 1 +
24
6 files changed, 131 insertions(+), 2 deletions(-)
24
6 files changed, 141 insertions(+), 2 deletions(-)
25
25
create mode 100644 src/pulsecore/inotify-wrapper.c
26
26
create mode 100644 src/pulsecore/inotify-wrapper.h
28
28
Index: pulseaudio-3.0/src/Makefile.am
29
29
===================================================================
30
--- pulseaudio-3.0.orig/src/Makefile.am 2013-04-17 17:30:30.912840834 +0200
31
+++ pulseaudio-3.0/src/Makefile.am 2013-04-17 17:30:30.900840834 +0200
30
--- pulseaudio-3.0.orig/src/Makefile.am 2013-04-18 13:25:39.017144501 +0200
31
+++ pulseaudio-3.0/src/Makefile.am 2013-04-18 13:25:39.009144501 +0200
32
32
@@ -840,6 +840,7 @@
33
33
pulsecore/fdsem.c pulsecore/fdsem.h \
34
34
pulsecore/g711.c pulsecore/g711.h \
39
39
pulsecore/modinfo.c pulsecore/modinfo.h \
40
40
Index: pulseaudio-3.0/src/daemon/main.c
41
41
===================================================================
42
--- pulseaudio-3.0.orig/src/daemon/main.c 2013-04-17 17:30:30.912840834 +0200
43
+++ pulseaudio-3.0/src/daemon/main.c 2013-04-17 17:30:30.904840834 +0200
42
--- pulseaudio-3.0.orig/src/daemon/main.c 2013-04-18 13:25:39.017144501 +0200
43
+++ pulseaudio-3.0/src/daemon/main.c 2013-04-18 13:25:39.009144501 +0200
45
45
#include <pulsecore/core-rtclock.h>
46
46
#include <pulsecore/core-scache.h>
113
113
Index: pulseaudio-3.0/src/pulsecore/inotify-wrapper.c
114
114
===================================================================
115
115
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
116
+++ pulseaudio-3.0/src/pulsecore/inotify-wrapper.c 2013-04-17 17:30:30.904840834 +0200
116
+++ pulseaudio-3.0/src/pulsecore/inotify-wrapper.c 2013-04-18 13:25:39.009144501 +0200
118
118
+#ifdef HAVE_CONFIG_H
119
119
+#include <config.h>
145
145
+ pa_io_event_flags_t events,
146
146
+ void *userdata) {
149
+ struct inotify_event event;
150
+ char name[NAME_MAX+1];
148
153
+ pa_inotify *i = userdata;
158
+ if (pa_read(fd, &buf, sizeof(buf), NULL) < (int) sizeof(buf.event))
159
+ pa_log_warn("inotify did not read a full event.");
161
+ pa_log_debug("inotify callback, event mask: 0x%x", (int) buf.event.mask);
153
163
+ pid_fd = pa_open_cloexec(i->filename, O_RDONLY
154
164
+#ifdef O_NOFOLLOW
186
+ if (inotify_add_watch(i->fd, filename, IN_ATTRIB|IN_CLOSE_WRITE|IN_DELETE_SELF|IN_MOVE_SELF) < 0) {
196
+ if (inotify_add_watch(i->fd, filename, IN_DELETE_SELF|IN_MOVE_SELF) < 0) {
187
197
+ pa_log("inotify_add_watch() failed: %s", pa_cstrerror(errno));
188
198
+ pa_inotify_stop(i);
211
221
Index: pulseaudio-3.0/src/pulsecore/inotify-wrapper.h
212
222
===================================================================
213
223
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
214
+++ pulseaudio-3.0/src/pulsecore/inotify-wrapper.h 2013-04-17 17:30:30.904840834 +0200
224
+++ pulseaudio-3.0/src/pulsecore/inotify-wrapper.h 2013-04-18 13:25:39.013144501 +0200
216
226
+#ifndef fooinotifywrapperhfoo
217
227
+#define fooinotifywrapperhfoo
229
239
Index: pulseaudio-3.0/src/pulsecore/pid.c
230
240
===================================================================
231
--- pulseaudio-3.0.orig/src/pulsecore/pid.c 2013-04-17 17:30:30.912840834 +0200
232
+++ pulseaudio-3.0/src/pulsecore/pid.c 2013-04-17 17:30:30.908840834 +0200
241
--- pulseaudio-3.0.orig/src/pulsecore/pid.c 2013-04-18 13:25:39.017144501 +0200
242
+++ pulseaudio-3.0/src/pulsecore/pid.c 2013-04-18 13:25:39.013144501 +0200
233
243
@@ -183,6 +183,11 @@
245
255
Index: pulseaudio-3.0/src/pulsecore/pid.h
246
256
===================================================================
247
--- pulseaudio-3.0.orig/src/pulsecore/pid.h 2013-04-17 17:30:30.912840834 +0200
248
+++ pulseaudio-3.0/src/pulsecore/pid.h 2013-04-17 17:30:30.908840834 +0200
257
--- pulseaudio-3.0.orig/src/pulsecore/pid.h 2013-04-18 13:25:39.017144501 +0200
258
+++ pulseaudio-3.0/src/pulsecore/pid.h 2013-04-18 13:25:39.013144501 +0200
249
259
@@ -22,6 +22,7 @@