Skip Navigation

My list of magic numbers for your turkey day enjoyment [2020]

rachelbythebay.com /w/2020/11/26/magic/
1
1 comments
  • -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.