2 ms·
Surely that gets(sbrk(0)) will not work since sbrk(0) returns a pointer to unmapped memory. Maybe you wanted sbrk(BUFSIZ)?
by fanf2 9y ago
Surely that gets(sbrk(0)) will not work since sbrk(0) returns a pointer to unmapped memory. Maybe you wanted sbrk(BUFSIZ)?
- geocar 9y agoWell, no actually: That still limits you to a gets of BUFSIZ. Just as we often grow the stack with page faults, you could grow the heap with page faults: Modern UNIX doesn't because this is another one of those "almost certainly a mistake", but: signal(SIGSEGV, grow); void grow(int _) { sbrk(PAGESZ); } should work.