Hacker News new | ask | show | jobs
by cyphar 3460 days ago
> I don't understand why it is limited to 255 chars. The kernel copies the string(s) into the programs memory so it would be a kernel bug if the program got a non null-terminated or too long string.

But you can also pass arguments to execve(2) which are not null-terminated.

1 comments

The kernel copies the strings you pass in the array of pointers. (haven't checked though, but it is better then the alternative of not copying and dealing with the mess)
The memory mapping is the same before and after execve(2), so I don't think it needs to be copied. I'll take a look though.
Maybe only a few pages remain as programs don't inherit memory from their parents. It could be done for those strings but consider that mappings are in 4k pages (so the rest of the page would have to be cleared to 0).