• palordrolap@kbin.social
    link
    fedilink
    arrow-up
    12
    ·
    6 months ago

    There was a system I was a user on once a long time ago, user being important, where I got into the habit of running kill -9 -1 to literally (SIG)KILL all processes to log out. It meant I didn’t leave anything running and I had already saved my work. Never had a problem with it. It only killed processes my account had access to, after all.

    Later I used it to log out of a system I was root on.

    root. oh no.

    There was no grinding and crunching of gears, but my brain plays that sound effect anyway.

    Thus the habit was very quickly unlearned.

  • Skull giver@popplesburger.hilciferous.nl
    link
    fedilink
    arrow-up
    4
    ·
    6 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!