【问题标题】:Will setproctitle cause proc/PID/cmdline to include env vars?setproctitle 会导致 proc/PID/cmdline 包含环境变量吗?
【发布时间】:2014-03-07 17:04:35
【问题描述】:

进程可以使用setproctitle(3) 更新/proc/PID/cmdline,但是strnlen(buffer, res) 何时返回len 小于res 中的this line

另一个问题是如果len 等于res,那么环境变量将包含在/proc/PID/cmdline 中吗?

【问题讨论】:

    标签: c linux linux-kernel proc


    【解决方案1】:
    1. strnlen 计算buffer 中的字符数,最多为res。这意味着它永远不会尝试超过buffer[res]。但是,如果字符串的长度小于res,则返回值len 将小于res

    2. 如果len 等于res,那么内核将需要为更大的名称腾出空间。

    【讨论】:

    • 你能给我解释一下this code吗?哪个分支会去here
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-05-15
    • 1970-01-01
    • 1970-01-01
    • 2010-09-16
    相关资源
    最近更新 更多