2

LC_ALL变量设置错误导致程序core事件

 2 years ago
source link: https://www.lujun9972.win/blog/2018/09/30/lc_all%E5%8F%98%E9%87%8F%E8%AE%BE%E7%BD%AE%E9%94%99%E8%AF%AF%E5%AF%BC%E8%87%B4%E7%A8%8B%E5%BA%8Fcore%E4%BA%8B%E4%BB%B6/index.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

LC_ALL变量设置错误导致程序core事件

使用自动发布工具启动应用时某个进程莫名其妙会core掉,但是通过ssh登陆服务器手工启动应用却一切正常

由于自动发布工具是模拟的ssh登陆手工操作的过程,因此跟是否登陆SHELL应该是无关的。

在对比了两次发布过程中进程的环境变量后(正常启动后 strings /proc/$pid/environ,然后在自动发布中运行 env 进行对比),发现两次发布 LC_ALL 这个环境是不同的。

正常发布时 LC_ALL 的值为 C, 而自动发布工具发布时,将本地的 LC_ALL 传递过去,设置成了 zh_CN.UTF-8.

LC_ALL (及其其他 LC_* 类的环境变量) 会影响到某些 C 函数(比如setlocale,ctype,multibyte,catopen,printf,localeconv,tolower,toupper等)的运行结果


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK