rb-fsevent 0.9.7 → 0.9.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6ec2a04c1e09fcc2b15f66a283c02222b102fef8
4
- data.tar.gz: 1a63e413a9d9cbf3fb71558322652d4d6ecc2f18
3
+ metadata.gz: 33b6645ea468e8ad531d5cc24e3b8ae9794a30a9
4
+ data.tar.gz: 2d775b72b9303d0e93068850a7d119315bcad81d
5
5
  SHA512:
6
- metadata.gz: b9d7321a62fbd19b4b25464a19b5ca23adbd79f7e1adcb015b70512c58814d782969654c99dd6e8863a496e81a8a63b2c950f1fe93409591fc6904d190b5ad6e
7
- data.tar.gz: 449890feca668e4827d2c679caf4b46a1ae11173b4a73064da0c09f8b267006adadd06029bea97a5ef85983d1641724209518e1179a27681d0330daff576229d
6
+ metadata.gz: 5cbb1ac611ea29a0fa14e72a8f016741e39bf0d9987717244ad9dbe14188a8c94f891687e12d0320f96dea49b47f5a9697deb189eb9751e42dda406b0a680e65
7
+ data.tar.gz: 2c87389ccab291b776189be56f12f322e0e26e2ea0ed1d22429f5d932b212788cf3e29e15ce02f762f82849d6a293e01e630955aaa01b7a0db17db69046c1711
@@ -113,27 +113,6 @@ static inline CFStringRef TSICTStringCreateStringFromIntermediateRepresentation(
113
113
  return string;
114
114
  }
115
115
 
116
- static inline CFDataRef TSICTStringCreateDataWithDataOfTypeAndFormat(CFDataRef data, TSITStringTag type, TSITStringFormat format)
117
- {
118
- CFRetain(data);
119
-
120
- if (format == kTSITStringFormatDefault) {
121
- format = TSICTStringGetDefaultFormat();
122
- }
123
-
124
- TStringIRep* rep = TSICTStringCreateWithDataOfTypeAndFormat(data, type, format);
125
- if (rep == NULL) {
126
- return NULL;
127
- }
128
-
129
- CFDataRef result = TSICTStringCreateDataFromIntermediateRepresentation(rep);
130
-
131
- TSICTStringDestroy(rep);
132
- CFRelease(data);
133
-
134
- return result;
135
- }
136
-
137
116
  static inline void TSICTStringAppendObjectToMutableDataWithFormat(CFTypeRef object, CFMutableDataRef buffer, TSITStringFormat format)
138
117
  {
139
118
  if (object == NULL) {
@@ -1,4 +1,5 @@
1
1
  #include "common.h"
2
+ #include "signal_handlers.h"
2
3
  #include "cli.h"
3
4
  #include "FSEventsFix.h"
4
5
 
@@ -470,6 +471,7 @@ static void callback(__attribute__((unused)) FSEventStreamRef streamRef,
470
471
 
471
472
  int main(int argc, const char* argv[])
472
473
  {
474
+ install_signal_handlers();
473
475
  parse_cli_settings(argc, argv);
474
476
 
475
477
  if (needs_fsevents_fix) {
@@ -0,0 +1,66 @@
1
+ #include "signal_handlers.h"
2
+ #include <fcntl.h>
3
+ #include <signal.h>
4
+ #include <stdio.h>
5
+ #include <stdlib.h>
6
+ #include <sys/time.h>
7
+ #include <unistd.h>
8
+
9
+
10
+ #define PPID_ALARM_INTERVAL 2 // send SIGALRM every this seconds
11
+
12
+
13
+ static pid_t orig_ppid;
14
+
15
+
16
+ static void signal_handler(int _) {
17
+ exit(EXIT_FAILURE);
18
+ }
19
+
20
+ static void check_ppid(void) {
21
+ if (getppid() != orig_ppid) {
22
+ exit(EXIT_FAILURE);
23
+ }
24
+ }
25
+
26
+ static void check_stdout_open(void) {
27
+ if (fcntl(STDOUT_FILENO, F_GETFD) < 0) {
28
+ exit(EXIT_FAILURE);
29
+ }
30
+ }
31
+
32
+ static void alarm_handler(int _) {
33
+ check_ppid();
34
+ check_stdout_open();
35
+ alarm(PPID_ALARM_INTERVAL);
36
+ signal(SIGALRM, alarm_handler);
37
+ }
38
+
39
+ static void die(const char *msg) {
40
+ fprintf(stderr, "\nFATAL: %s\n", msg);
41
+ abort();
42
+ }
43
+
44
+ static void install_signal_handler(int sig, void (*handler)(int)) {
45
+ if (signal(sig, handler) == SIG_ERR) {
46
+ die("Could not install signal handler");
47
+ }
48
+ }
49
+
50
+ void install_signal_handlers(void) {
51
+ // check pipe is still connected
52
+ check_stdout_open();
53
+
54
+ // watch getppid() every PPID_ALARM_INTERVAL seconds
55
+ orig_ppid = getppid();
56
+ if (orig_ppid <= 1) {
57
+ die("prematurely zombied");
58
+ }
59
+ install_signal_handler(SIGALRM, alarm_handler);
60
+ alarm(PPID_ALARM_INTERVAL);
61
+
62
+ // be sure to exit on SIGHUP, SIGPIPE
63
+ install_signal_handler(SIGHUP, signal_handler);
64
+ install_signal_handler(SIGPIPE, signal_handler);
65
+ }
66
+
@@ -0,0 +1,16 @@
1
+ /**
2
+ * @headerfile signal_handlers.h
3
+ * Signal handlers to stop the zombie hordes
4
+ *
5
+ * Catch and handle signals better so that we die faster like a good meat puppet.
6
+ */
7
+
8
+
9
+ #ifndef fsevent_watch_signal_handlers_h
10
+ #define fsevent_watch_signal_handlers_h
11
+
12
+
13
+ void install_signal_handlers(void);
14
+
15
+
16
+ #endif // fsevent_watch_signal_handlers_h
@@ -1,5 +1,5 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
 
3
3
  class FSEvent
4
- VERSION = '0.9.7'
4
+ VERSION = '0.9.8'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rb-fsevent
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.7
4
+ version: 0.9.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thibaud Guillaume-Gentil
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-12-29 00:00:00.000000000 Z
12
+ date: 2016-10-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -80,6 +80,8 @@ files:
80
80
  - ext/fsevent_watch/compat.h
81
81
  - ext/fsevent_watch/defines.h
82
82
  - ext/fsevent_watch/main.c
83
+ - ext/fsevent_watch/signal_handlers.c
84
+ - ext/fsevent_watch/signal_handlers.h
83
85
  - ext/rakefile.rb
84
86
  - lib/rb-fsevent.rb
85
87
  - lib/rb-fsevent/fsevent.rb
@@ -105,7 +107,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
105
107
  version: '0'
106
108
  requirements: []
107
109
  rubyforge_project:
108
- rubygems_version: 2.5.1
110
+ rubygems_version: 2.4.5.1
109
111
  signing_key:
110
112
  specification_version: 4
111
113
  summary: Very simple & usable FSEvents API