Sha256: 1faac48b5fb202db036c0897138a55f04e45d624907a26d0acdd226521df0c96

Contents?: true

Size: 866 Bytes

Versions: 3

Compression:

Stored size: 866 Bytes

Contents

##########################################################################
# example_fork_waitpid.rb
#
# Generic test script for futzing around with the traditional form of
# fork/wait, plus waitpid and waitpid2.
#
# You can run this code via the 'example:fork_waitpid' task.
##########################################################################
require 'win32/process'

puts "VERSION: " + Process::WIN32_PROCESS_VERSION

pid = Process.fork
puts "PID1: #{pid}"

#child
if pid.nil?
  7.times{ |i|
    puts "Child: #{i}"
    sleep 1
  }
  exit(-1)
end

pid2 = Process.fork
puts "PID2: #{pid2}"

#child2
if pid2.nil?
  7.times{ |i|
    puts "Child2: #{i}"
    sleep 1
  }
  exit(1)
end

#parent
2.times { |i|
  puts "Parent: #{i}"
  sleep 1
}

p Process.waitpid2(pid)
p Process.waitpid2(pid2)

puts "Continuing on..."

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
win32-process-0.6.6 examples/example_fork_waitpid.rb
win32-process-0.6.5 examples/example_fork_waitpid.rb
win32-process-0.6.4 examples/example_fork_waitpid.rb