Where is PATH_MAX defined in Linux?
Be aware, that it is still unclear if PATH_MAX
defines a maximum length with or without a trailing nul byte. It may be one or the other on different operating systems. If you can't or don't want to check which case it is during compilation, it's safer to force artificial limit of PATH_MAX - 1
. Better safe than sorry. (Obviously, you still need to reserve at least PATH_MAX
bytes of memory to buffer the string.)