import os
import socket
import time


SERVER_ADDRESS = (HOST, PORT) = '', 8888
REQUEST_QUEUE_SIZE = 5


def handle_request(client_connection):
    request = client_connection.recv(1024)
    print 'Child PID: {pid}. Parent PID: {ppid}'.format(pid=os.getpid(), ppid=os.getppid())
    print request.decode()
    http_response = '''\
HTTP/1.1 200 OK

Hello World!
'''
    client_connection.sendall(http_response)
    time.sleep(60)


def serve_forever():
    listen_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    listen_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
    listen_socket.bind(SERVER_ADDRESS)
    listen_socket.listen(REQUEST_QUEUE_SIZE)
    print 'Serving HTTP on port {port} ...'.format(port=PORT)
    print 'Parent PID (PPID): {pid}\n'.format(pid=os.getpid())

    while True:
        client_connection, client_address = listen_socket.accept()
        pid = os.fork()
        if pid == 0:
            listen_socket.close()
            handle_request(client_connection)
            client_connection.close()
            os._exit(0)
        else:
            client_connection.close()

if __name__ == '__main__':
    serve_forever()

@@ -1,12 +1,39 @@
+import errno%0Aimport signal%0A
 import os%0Aim
@@ -124,16 +124,78 @@
 E = 5%0A%0A%0A
+def grim_reaper(signum, frame):%0A    pid, status = os.wait()%0A%0A%0A
 def hand
@@ -510,10 +510,9 @@
 eep(
-60
+3
 )%0A%0A%0A
@@ -884,16 +884,64 @@
 pid())%0A%0A
+    signal.signal(signal.SIGCHLD, grim_reaper)%0A%0A
     whil
@@ -948,16 +948,33 @@
 e True:%0A
+        try:%0A    
         
@@ -1032,16 +1032,178 @@
 ccept()%0A
+        except IOError as e:%0A            code, msg = e.args%0A            if code == errno.EINTR:%0A                continue%0A            else:%0A                raise%0A%0A
         

solve zombie process: use signal handler