我有以下线程python脚本:
#!/usr/bin/python
from threading import Thread, Event
def doSum(num):
abc = 1
abc = abc + num
if __name__ == '__main__':
print "Content-Type: text/html\r\n\r\n"
p1 = Thread(target=doSum, args=(14,))
print "thread created"
p1.start()
print "thread started"
p1.join()
print "thread joining"
print "done"
我故意创建'doSum'函数,不对此测试做任何有用的事情。此脚本从命令行运行正常,但每次都在“p1.start()”上崩溃。在cgi进程上运行strace给出:
> clone(child_stack=0x7fdcad515ff0,
> flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID,
> parent_tidptr=0x7fdcad5169d0, tls=0x7fdcad516700,
> child_tidptr=0x7fdcad5169d0) = 29570 futex(0xf8c8f0,
> FUTEX_WAIT_PRIVATE, 0, NULL <unfinished ...>
> +++ killed by SIGABRT +++
为什么线程在作为cgi运行但不在命令行上时开始死? Web服务器正在运行suexec,因此进程在cgi和命令行情况下都在同一用户下运行。
我的提供程序正在运行Python 2.6.6。