• @canpolat
    link
    English
    611 months ago

    -1 is what you get back from fork() when it fails. Normally, it returns a pid_t which is positive if you’re the parent, or zero if you’re the child.

    -1, when handed to kill() on Linux, means “target every process but myself and init”. Therefore, when you take the return value from fork(), fail to check for an error, and later hand that value to kill(), you might just kill everything else on the machine.

    Great story.