: pts/ : pts/ : pts/ : : python signal-demo py : : ps - : : -bash ]kill - got signal at sun apr : : sigchld caught ]kill - got signal at sun apr : : sigchld caught ]kill - [ ]killed python signal-demo py nowto apply all of this signal knowledge to killing zombiessimply set the sigchld signal handler to the sig_ign ignore handler actionon systems where this assignment is supportedchild processes will be cleaned up when they exit the forking server variant shown in example - uses this trick to manage its children example - pp \internet\sockets\fork-server-signal py ""same as fork-server pybut use the python signal module to avoid keeping child zombie processes after they terminateinstead of an explicit reaper loop before each new connectionsig_ign means ignoreand may not work with sig_chld child exit signal on all platformssee linux documentation for more about the restartability of socket accept call interrupted with signal""import ostimesyssignalsignal from socket import myhost 'myport get socket constructor and constants server machine'means local host listen on non-reserved port number sockobj socket(af_inetsock_streamsockobj bind((myhostmyport)sockobj listen( signal signal(signal sigchldsignal sig_ignmake tcp socket object bind it to server port number up to pending connects avoid child zombie processes def now()return time ctime(time time()time on server machine def handleclient(connection)child process repliesexits time sleep( simulate blocking activity while truereadwrite client socket data connection recv( if not databreak reply 'echo=>% at % (datanow()connection send(reply encode()connection close(os _exit( def dispatcher()while truelisten until process killed wait for next connectionhandling multiple clients