socket question:socket.error:(4,'Interrupted system call')
Donn Cave
donn at drizzle.com
Mon Dec 17 02:02:29 EST 2001
Quoth =?gb2312?B?1cXJ2bPb?= <zhangsc at neusoft.com>:
| I have compiled a program to deal with Zombie process which caused by child process,it follows:
| ...
| ipsock=socket.socket(socket.AF_INET,10,8)
| while 1:
| recvpack=ipsock.recv(1024)
| ...
| def sig_chld(signum, frame):
| os.waitpid(-1,os.WNOHANG);
| signal.signal(signal.SIGCHLD,sig_chld);
| ret=os.fork()
| if ret==0: #child process
| .....
|
| It raise a error:
| Traceback (most recent call last):
| File "d88.py", line 26, in ?
| recvpack=ipsock.recv(1024)
| socket.error: (4, 'Interrupted system call')
|
| Why is error? How to correct it? Any ideas will be appreciated.
You asked for SIGCHLD, it arrived during recv() and interrupted it.
This would happen with C just as it would in Python. In C it might
be worth your while to deal with it, but Python is so awkward with
signals anyway that in my opinion it's better to avoid them - no
signals.
I'm not sure I understand how the sig_chld handler fits into your
application, but if possible, I would simply call waitpid() at some
convenient interval to reap zombie processes.
Donn Cave, donn at drizzle.com
More information about the Python-list
mailing list