kill_process 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/Gemfile +9 -0
- data/LICENSE.txt +21 -0
- data/README.md +32 -0
- data/Rakefile +6 -0
- data/ext/extconf.rb +4 -0
- data/ext/kill_process_native.c +44 -0
- data/kill_process.gemspec +24 -0
- data/lib/kill_process/version.rb +3 -0
- data/lib/kill_process.rb +10 -0
- metadata +97 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 0eee211d248e931543803767cb234519d0ae612a
|
4
|
+
data.tar.gz: 4d3d7928b586be170c5e00bedc8f4b2b3e4f838d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 91595b1ae889a83224f0cec0fff72c7f0c8677d01199e82bb07e33387b01fcec1ebd61f265f0ee84dfcae96e8e977ac620cde12e1408dda5a76661271f61a004
|
7
|
+
data.tar.gz: a036e1eafbc7179123c2fe9dddcea80907a6fe05955784a3d35acc812a81d0ee1c4939bb0c7e1bfd2c63f50426a2b50925b0c575655976f2d30a7e63d43f0231
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Jacob Green
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# KillProcess
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/kill_process`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'kill_process'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install kill_process
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
KillProcess.after(10)
|
27
|
+
```
|
28
|
+
|
29
|
+
## License
|
30
|
+
|
31
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
32
|
+
|
data/Rakefile
ADDED
data/ext/extconf.rb
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
#include <math.h>
|
2
|
+
#include <ruby.h>
|
3
|
+
#include <signal.h>
|
4
|
+
#include <time.h>
|
5
|
+
#include <pthread.h>
|
6
|
+
|
7
|
+
VALUE rb_posix_timer_set(VALUE self, VALUE seconds) {
|
8
|
+
struct sigevent sev;
|
9
|
+
timer_t tidlist;
|
10
|
+
int return_val;
|
11
|
+
struct timespec zero_time;
|
12
|
+
struct timespec timeout_value;
|
13
|
+
struct itimerspec timer_spec;
|
14
|
+
double dbl_seconds = NUM2DBL(seconds);
|
15
|
+
|
16
|
+
zero_time.tv_sec = 0;
|
17
|
+
zero_time.tv_nsec = 0;
|
18
|
+
|
19
|
+
timeout_value.tv_sec = (int)floor(dbl_seconds);
|
20
|
+
timeout_value.tv_nsec = 0;
|
21
|
+
|
22
|
+
timer_spec.it_interval = zero_time;
|
23
|
+
timer_spec.it_value = timeout_value;
|
24
|
+
|
25
|
+
sev.sigev_notify = SIGEV_SIGNAL;
|
26
|
+
sev.sigev_signo = 9; //SIGKILL
|
27
|
+
|
28
|
+
return_val = timer_create(CLOCK_REALTIME, &sev, &tidlist);
|
29
|
+
if (return_val != 0) {
|
30
|
+
rb_sys_fail(0);
|
31
|
+
}
|
32
|
+
return_val = timer_settime(tidlist, 0, &timer_spec, NULL);
|
33
|
+
if (return_val != 0) {
|
34
|
+
rb_sys_fail(0);
|
35
|
+
}
|
36
|
+
|
37
|
+
return Qtrue;
|
38
|
+
}
|
39
|
+
|
40
|
+
void Init_kill_process_native(void) {
|
41
|
+
VALUE kill_process_module = rb_const_get(rb_cObject, rb_intern("KillProcess"));
|
42
|
+
|
43
|
+
rb_define_singleton_method(kill_process_module, "posix_timer_set", rb_posix_timer_set, 1);
|
44
|
+
}
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'kill_process/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "kill_process"
|
8
|
+
spec.version = KillProcess::VERSION
|
9
|
+
spec.authors = ["Jacob Green"]
|
10
|
+
spec.email = ["jacob@nationbuilder.com"]
|
11
|
+
|
12
|
+
spec.summary = 'Use UNIX posix timers to guarantee a process dies after N seconds'
|
13
|
+
spec.description = 'Use UNIX posix timers to guarantee a process dies after N seconds'
|
14
|
+
spec.homepage = "https://github.com/Jacobkg/kill_process"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.extensions = 'ext/extconf.rb'
|
18
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.11"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
spec.add_development_dependency 'rake-compiler'
|
24
|
+
end
|
data/lib/kill_process.rb
ADDED
metadata
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: kill_process
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jacob Green
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-01-28 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.11'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.11'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake-compiler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: Use UNIX posix timers to guarantee a process dies after N seconds
|
56
|
+
email:
|
57
|
+
- jacob@nationbuilder.com
|
58
|
+
executables: []
|
59
|
+
extensions:
|
60
|
+
- ext/extconf.rb
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- ".gitignore"
|
64
|
+
- Gemfile
|
65
|
+
- LICENSE.txt
|
66
|
+
- README.md
|
67
|
+
- Rakefile
|
68
|
+
- ext/extconf.rb
|
69
|
+
- ext/kill_process_native.c
|
70
|
+
- kill_process.gemspec
|
71
|
+
- lib/kill_process.rb
|
72
|
+
- lib/kill_process/version.rb
|
73
|
+
homepage: https://github.com/Jacobkg/kill_process
|
74
|
+
licenses:
|
75
|
+
- MIT
|
76
|
+
metadata: {}
|
77
|
+
post_install_message:
|
78
|
+
rdoc_options: []
|
79
|
+
require_paths:
|
80
|
+
- lib
|
81
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - ">="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0'
|
91
|
+
requirements: []
|
92
|
+
rubyforge_project:
|
93
|
+
rubygems_version: 2.4.8
|
94
|
+
signing_key:
|
95
|
+
specification_version: 4
|
96
|
+
summary: Use UNIX posix timers to guarantee a process dies after N seconds
|
97
|
+
test_files: []
|