From: Joseph McDonald Date: 2001-06-16T09:48:39+09:00 Subject: [ruby-talk:16520] Re: forking server Here's a stab at a forking server. The problem is that it exits after the first connection and I don't understand why... Can anyone enlighten me? thanks, -joe #!/usr/local/bin/ruby require 'socket' trap("CLD") { pid = Process.wait puts "Child pid #{pid}: terminated" exit } s = TCPServer.new("0.0.0.0",8888) while(new_sock = s.accept) pid = fork puts "pid: #{pid.inspect}" if(pid == nil) # Child process # do stuff here... line = new_sock.gets line.chop! puts line new_sock.puts "you said: #{line}" exit end end puts "exiting... (never prints, but we do exit...)" s.close