Skip to content

Instantly share code, notes, and snippets.

@huyderman
Created April 21, 2015 10:45
Show Gist options
  • Select an option

  • Save huyderman/6c50dfde4c5cc611b023 to your computer and use it in GitHub Desktop.

Select an option

Save huyderman/6c50dfde4c5cc611b023 to your computer and use it in GitHub Desktop.

Revisions

  1. huyderman created this gist Apr 21, 2015.
    12 changes: 12 additions & 0 deletions fork.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    require 'logger'

    logger = Logger.new STDOUT

    function = -> { logger.info "Something that takes a while..." }

    # fork is not portable
    if Process.respond_to?(:fork)
    Process.detach fork(&function)
    else
    function
    end