Encoding of /proc//cmdline files

character encodingproc

I am thinking about working with the /proc/<pid>/cmdline files, but I couldn't find any documentation about the file encoding. The only piece of information I could find is located in the man page:

 /proc/[pid]/cmdline
    This holds the complete command line for the process, unless the process is a zombie.  In the  latter
    case, there is nothing in this file: that is, a read on this file will return 0 characters.  The com‐
    mand-line arguments appear in this file as a set of strings separated by null bytes  ('\0'),  with  a
    further null byte after the last string.

What is the encoding of the cmdline file?

Best Answer

The command-line arguments appear in this file as a set of strings separated by null bytes ('\0'), with a further null byte after the last string.

It is all you need. You have got command and its arguments separated by null byte \0. Encoding of the characters is based on the locale, but it should not really matter.

Do you have some specific example where you need help?