O
Oliver Peng
Now I am writing a server code to handle each connection by forking a
new process. Here is the code:
@tcpServer = TCPServer.new(host, port)
while true
if tcp = @tcpServer.accept
fork do
// handle all request in this connection
end
tcp && tcp.close
end
end
@tcpServer.close_read
@tcpServer.close_write
I also set up trap to handle CLD signal:
trap("CLD") {
pid_info_array = Process.waitall
}
After a period of time, I got the error:
SystemStackError: stack level too deep
The position is at the line of Process.waitall.
I have tried to use Process.wait, but this problem still exist.
Any ideas. Thanks.
new process. Here is the code:
@tcpServer = TCPServer.new(host, port)
while true
if tcp = @tcpServer.accept
fork do
// handle all request in this connection
end
tcp && tcp.close
end
end
@tcpServer.close_read
@tcpServer.close_write
I also set up trap to handle CLD signal:
trap("CLD") {
pid_info_array = Process.waitall
}
After a period of time, I got the error:
SystemStackError: stack level too deep
The position is at the line of Process.waitall.
I have tried to use Process.wait, but this problem still exist.
Any ideas. Thanks.