How to parse /proc/pid/cmdline

前端 未结 7 1906
盖世英雄少女心
盖世英雄少女心 2021-02-01 18:51

I\'m trying to split the cmdline of a process on Linux but it seems I cannot rely on it to be separated by \'\\0\' characters. Do you know why sometimes the \'\\0\' character is

相关标签:
7条回答
  • 2021-02-01 19:46

    A shot in the dark, but is it possible that \0 is separating terms and spaces are separating words within a term? For example,

    myprog "foo bar" baz
    

    might appear in /proc/pid/cmdline as...

    /usr/bin/myprog\0foo bar\0baz
    

    Complete guess here, I can't seem to find any spaces on one of my Linux boxes.

    0 讨论(0)
提交回复
热议问题