• Skull giver@popplesburger.hilciferous.nl
    link
    fedilink
    arrow-up
    1
    ·
    8 months ago

    Killing -1 will kill all processes you can kill.

    fork() will return negative numbers to indicate errors, 0 to indicate that the code is now in a new thread, or positive numbers to indicate the process ID of the new thread.

    Some programs will kill all threads they started on exit, by sending a kill signal to every thread ID they received when starting new threads.

    Not many developers realise fork() can fail, or that it returns a negative value, or that killing negative values can have weird implications.

    This combination of API designs has led to some quite puzzling but reports that go a little like “whenever I close this program, I get logged out”. Remember to always check for negative numbers when talking to the Unix API!