child_subreaper 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: e4dc9cde111885417ee97eead4ec2078c52eca76fd5ede0853c98cd1bdec8a35
4
+ data.tar.gz: 7c023f9d22d61964fef887c9a9bfadf69028e7355cbd5a920860dd0a71210c16
5
+ SHA512:
6
+ metadata.gz: 8f4949f44ed7d32fc50650a2841529fe5c372f90e4504f2c7a2d4bb4e8a9124df2679edb4578aab2795f949993b3645f048db2b3f6c3e9f9de42ba4808944edb
7
+ data.tar.gz: 0d3a78b8c2be52102de625b92909b862818a01f6d0beb90f86195fb827069b76e79948178d9567604e07bedf14c6451f8b104352fee646b0afa013e02435a685
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2022-07-04
4
+
5
+ - Initial release
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in child_subreaper.gemspec
6
+ gemspec
7
+
8
+ gem "rake"
9
+
10
+ gem "rake-compiler"
11
+
12
+ gem "minitest", "~> 5.0"
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2022 Shopify
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,33 @@
1
+ # ChildSubreaper
2
+
3
+ Ruby binding to call `prctl(PR_SET_CHILD_SUBREAPER)`. See [`prctl(2)`](https://man7.org/linux/man-pages/man2/prctl.2.html).
4
+
5
+ ## Installation
6
+
7
+ Install the gem and add to the application's Gemfile by executing:
8
+
9
+ $ bundle add child_subreaper
10
+
11
+ If bundler is not being used to manage dependencies, install the gem by executing:
12
+
13
+ $ gem install child_subreaper
14
+
15
+ ## Usage
16
+
17
+ ```ruby
18
+ require "child_subreaper"
19
+ ```
20
+
21
+ ## Development
22
+
23
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
24
+
25
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
26
+
27
+ ## Contributing
28
+
29
+ Bug reports and pull requests are welcome on GitHub at https://github.com/Shopify/child_subreaper.
30
+
31
+ ## License
32
+
33
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rake/testtask"
5
+
6
+ Rake::TestTask.new(:test) do |t|
7
+ t.libs << "test"
8
+ t.libs << "lib"
9
+ t.test_files = FileList["test/**/test_*.rb"]
10
+ end
11
+
12
+ require "rake/extensiontask"
13
+
14
+ if RUBY_PLATFORM =~ /linux/i
15
+ task build: :compile
16
+
17
+ Rake::ExtensionTask.new("child_subreaper") do |ext|
18
+ ext.lib_dir = "lib/child_subreaper"
19
+ end
20
+
21
+ task default: %i[clobber compile test]
22
+ else
23
+ task default: :test
24
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/child_subreaper/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "child_subreaper"
7
+ spec.version = ChildSubreaper::VERSION
8
+ spec.authors = ["Jean Boussier"]
9
+ spec.email = ["jean.boussier@gmail.com"]
10
+
11
+ spec.summary = "Ruby binding to call prctl(PR_SET_CHILD_SUBREAPER)"
12
+ spec.homepage = "https://github.com/Shopify/child_subreaper"
13
+ spec.license = "MIT"
14
+ spec.required_ruby_version = ">= 2.0.0"
15
+
16
+ spec.metadata["allowed_push_host"] = "https://rubygems.org"
17
+
18
+ spec.metadata["homepage_uri"] = spec.homepage
19
+ spec.metadata["source_code_uri"] = spec.homepage
20
+ spec.metadata["changelog_uri"] = File.join(spec.homepage, "blob/master/CHANGELOG.md")
21
+
22
+ # Specify which files should be added to the gem when it is released.
23
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
24
+ spec.files = Dir.chdir(__dir__) do
25
+ `git ls-files -z`.split("\x0").reject do |f|
26
+ (f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
27
+ end
28
+ end
29
+ spec.bindir = "exe"
30
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
31
+ spec.require_paths = ["lib"]
32
+ spec.extensions = ["ext/child_subreaper/extconf.rb"]
33
+ end
@@ -0,0 +1,25 @@
1
+ #include <sys/prctl.h>
2
+ #include "ruby.h"
3
+
4
+ static void set_child_subreaper(int value) {
5
+ if (prctl(PR_SET_CHILD_SUBREAPER, value) < 0) {
6
+ rb_sys_fail("prctl(2) PR_SET_CHILD_SUBREAPER");
7
+ }
8
+ }
9
+
10
+ static VALUE enable_child_subreaper(VALUE module) {
11
+ set_child_subreaper(1);
12
+ return Qtrue;
13
+ }
14
+
15
+ static VALUE disable_child_subreaper(VALUE module) {
16
+ set_child_subreaper(0);
17
+ return Qtrue;
18
+ }
19
+
20
+ void Init_child_subreaper(void)
21
+ {
22
+ VALUE rb_mChildSubreaper = rb_define_module("ChildSubreaper");
23
+ rb_define_singleton_method(rb_mChildSubreaper, "enable", enable_child_subreaper, 0);
24
+ rb_define_singleton_method(rb_mChildSubreaper, "disable", disable_child_subreaper, 0);
25
+ }
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "mkmf"
4
+
5
+ if Process.respond_to?(:fork) && have_const("PR_SET_CHILD_SUBREAPER", "sys/prctl.h")
6
+ create_makefile("child_subreaper/child_subreaper")
7
+ else
8
+ File.write("Makefile", dummy_makefile($srcdir).join)
9
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ChildSubreaper
4
+ VERSION = "0.1.0"
5
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "child_subreaper/version"
4
+
5
+ module ChildSubreaper
6
+ AVAILABLE = begin
7
+ require "child_subreaper/child_subreaper"
8
+ true
9
+ rescue LoadError
10
+ false
11
+ end
12
+
13
+ unless AVAILABLE
14
+ def self.enable
15
+ false
16
+ end
17
+
18
+ def self.disable
19
+ false
20
+ end
21
+ end
22
+ end
metadata ADDED
@@ -0,0 +1,58 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: child_subreaper
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Jean Boussier
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2022-07-04 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description:
14
+ email:
15
+ - jean.boussier@gmail.com
16
+ executables: []
17
+ extensions:
18
+ - ext/child_subreaper/extconf.rb
19
+ extra_rdoc_files: []
20
+ files:
21
+ - CHANGELOG.md
22
+ - Gemfile
23
+ - LICENSE.txt
24
+ - README.md
25
+ - Rakefile
26
+ - child_subreaper.gemspec
27
+ - ext/child_subreaper/child_subreaper.c
28
+ - ext/child_subreaper/extconf.rb
29
+ - lib/child_subreaper.rb
30
+ - lib/child_subreaper/version.rb
31
+ homepage: https://github.com/Shopify/child_subreaper
32
+ licenses:
33
+ - MIT
34
+ metadata:
35
+ allowed_push_host: https://rubygems.org
36
+ homepage_uri: https://github.com/Shopify/child_subreaper
37
+ source_code_uri: https://github.com/Shopify/child_subreaper
38
+ changelog_uri: https://github.com/Shopify/child_subreaper/blob/master/CHANGELOG.md
39
+ post_install_message:
40
+ rdoc_options: []
41
+ require_paths:
42
+ - lib
43
+ required_ruby_version: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: 2.0.0
48
+ required_rubygems_version: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: '0'
53
+ requirements: []
54
+ rubygems_version: 3.3.7
55
+ signing_key:
56
+ specification_version: 4
57
+ summary: Ruby binding to call prctl(PR_SET_CHILD_SUBREAPER)
58
+ test_files: []