我目前正在为 VK 社交网络编写一个基于插件的服务器。插件系统是 YAPSY,进程正在使用os.fork()
.
我已经为所述服务器编写了一个文件服务器插件。在我启动它之后它工作得很好,但是当我关闭我用来启动它的终端会话时(我以 root 身份运行它),LIST
用于返回文件/文件夹列表的命令开始抛出[Errno 5] Input/output error
.
我os.listdir
用于获取文件夹内容如下:
elif cmd == u'list':
flist = os.listdir(self.cwd+'/'+('' if len(args)==0 else args[0]))
otp = "Listing of "+(self.cwd.replace(self.topdirpath, "<root>") if len(args) == 0 else self.cwd.replace(self.topdirpath, "<root>")+"/"+args[0])+':\n'
num = 0
flist.sort()
for fi in flist:
otp += "["+str(num)+"] "+('-DIR- ' if os.path.isdir(self.cwd+'/'+('' if len(args)==0 else args[0])+'/'+fi) else '')+str(fi)+"\n"
num += 1
self.fSay(otp,vk,'200 LIST OK')
return True
虽然我没有关闭启动服务器的 SSH 会话,但它工作得很好:
>> #$list
<< Listing of <root>:
[0] -DIR- AniArt
[1] -DIR- gifs
[2] -DIR- inbox
但是,一旦我注销 SSH,事情就变得很奇怪:
>> #$list
<< libakcore longpoll server
There was an error processing your request. More info:
[Errno 5] Input/output error
由于没有对文件夹内容进行任何更改,并且可以从同一用户手动访问,因此我不知道问题出在其中一个os.fork()
或os.listdir()
可能同时存在于两者中。但是,可以肯定的是,我是从单独的线程还是直接从分叉的服务器线程调用它都没有关系。
任何帮助将非常感激。提前致谢。