我foo用 Python寫了一個 RPC 服務器,我用它去妖魔化了start-stop-daemon --start --quiet --background \
--make-pidfile \
--pidfile /var/run/foo.pid \
-- /opt/foo一切正常,除了在我的守護進程中每次使用subprocess.check_call(some_cmd)或os.popen(some_cmd).read(1048576)與我foo在前臺開始時的情況相比都返回一個空字符串。外部程序some_cmd仍然成功執行(正如我在日志中看到的那樣),但我無法訪問它打印到標準輸出的內容。為什么會這樣,我可以對start-stop-daemon調用或我的 Python 代碼進行哪些更改以解決此問題?PS:我發現只有某些命令的輸出現在是空的:subprocess.check_output('echo "Hello World"', shell=True)仍然表現正常,而subprocess.check_output('/etc/init.d/apache2 --nocolor reload', shell=True)現在的輸出是空的。
添加回答
舉報
0/150
提交
取消