Socket
Book a DemoInstallSign in
Socket

ruby_is_forked

Package Overview
Dependencies
Maintainers
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ruby_is_forked

0.0.1
bundlerRubygems
Version published
Maintainers
2
Created
Source

= ruby_is_forked

Forked Ruby process inherit some resources from parent processes, on most platforms.

For example a File opened in a parent process is visible and shared in forked children:

file = File.open("/dev/null") puts "Parent: #{$$}: #{file.object_id}" fork { puts "Child: #{$$}: #{file.object_id}" } puts "Parent after fork: #{$$}: #{file.object_id}" Thread.new { puts "Thread: #{file.object_id}" }

Sample Output:

Parent: 27282: 153210860 Child: 29777: 153210860 Parent after fork: 27282: 153210860 Thread: 153210860

Using ruby_is_forked:

require 'ruby_is_forked/process_callbacks' file = File.open("/dev/null") Process.add_callback_in_child! lambda { | pid | file = File.open("/dev/null") } puts "Parent #{$$}: #{file.object_id}" fork { puts "Child: #{$$}: #{file.object_id}" } puts "Parent after fork: #{$$}: #{file.object_id}" Thread.new { puts "Thread: #{file.object_id}" }

Sample Output:

Parent 31583: 90260550 Child: 31627: 152197900 Parent after fork: 31583: 90260550 Thread: 90260550

== Functionality

  • RubyIsForked::ForkCallback ** Callbacks in children (and parents) of Process.fork (and Kernel#fork).
  • RubyIsForked::Process ** Provides Process.current and Process.local variable abstraction.

== See Also

  • http://github.com/kstephens/rails_is_forked

== Contributing to ruby_is_forked

  • Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
  • Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
  • Fork the project
  • Start a feature/bugfix branch
  • Commit and push until you are happy with your contribution
  • Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
  • Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.

== Copyright

Copyright (c) 2011 Kurt Stephens. See LICENSE.txt for further details.

FAQs

Package last updated on 01 May 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.