Redefine stdout in FastCGI and Octave

倖福魔咒の 提交于 2021-01-28 02:00:30

问题


I'm working on implementing an Octave interpreter inside of an FastCGI session using C/C++ in Ubuntu Linux. The problem I'm running into is that FCGI redirects stdout to FCGI_stdout, but the precompiled Octave headers manage to still use the normal stdout which ends up in Apache's error.log instead of printed to the browser.

Do any of you know a way to redirect Octave from using the system's stdout to use FCGI's stdout? Or even just to have it redirect stdout to a file without having to modify Octave's code and recompile.

Thanks


回答1:


To answer my own question if anybody else comes this way: Specifically setting stdout in octave doesn't seem to work, and neither do any attempts to temporarily redirect stdout at the system level. However, octave has the command dup2, used as described here:

http://octave.1599824.n4.nabble.com/dup2-on-stdout-or-using-disp-on-another-file-stream-td1611884.html

This can be used to redirect octave's stdout to a file to be read by another program (or likely to fast-cgi's own stdout stream once you have the PID)



来源:https://stackoverflow.com/questions/4230200/redefine-stdout-in-fastcgi-and-octave

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!