Hacker News new | past | comments | ask | show | jobs | submit login

Surely that gets(sbrk(0)) will not work since sbrk(0) returns a pointer to unmapped memory. Maybe you wanted sbrk(BUFSIZ)?



Well, 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.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: