Skip to content

Instantly share code, notes, and snippets.

@dylanahsmith
Last active January 15, 2019 12:46

Revisions

  1. dylanahsmith revised this gist Apr 7, 2014. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion test.rb
    Original file line number Diff line number Diff line change
    @@ -7,7 +7,6 @@
    pid = fork do
    loop do
    client = Mysql2::Client.new
    client.ping or abort("ping failed")
    client.close
    end
    end
  2. dylanahsmith created this gist Apr 7, 2014.
    19 changes: 19 additions & 0 deletions test.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    #!/usr/bin/env ruby

    require 'mysql2'

    trap("USR2") {}

    pid = fork do
    loop do
    client = Mysql2::Client.new
    client.ping or abort("ping failed")
    client.close
    end
    end

    until Process.waitpid(pid, Process::WNOHANG)
    Process.kill("USR2", pid)
    sleep 0.01
    end
    puts $?.to_s