• Krik@lemmy.dbzer0.com
    link
    fedilink
    arrow-up
    56
    ·
    edit-2
    1 day ago

    In university we were taught C programming. We started with simple things like loops and stuff. After a while the topic processes, threads & stuff came up and of course we were instructed to use that.

    In the computer lab there where only thin clients so everything actually ran on the server.

    A good friend of mine - not know what was about to happen - entered:

    while (true) {
        fork();
    }
    

    Astoundingly it took a whole minute until the server froze. 🤣
    That was the same server most of the school stuff ran on. So nearly everything went down. 😂
    He got scolded by the sysadmin the next day but nothing serious happened.

    • tetris11@lemmy.ml
      link
      fedilink
      arrow-up
      2
      ·
      edit-2
      6 hours ago

      :(){ :|:& };:

      or (more clearly written):

      function forkbomb() {
          forkbomb | forkbomb &  ## background the process whilst recursing
          ## the pipe ensures that both instances are called at the same time, instead of waiting on the other
          ## without the pipe, you just get a linear increase in processes. Slow bomb. We want fast.
      };
      forkbomb  ## start it all off
      
    • optional@sh.itjust.works
      link
      fedilink
      arrow-up
      58
      arrow-down
      1
      ·
      1 day ago

      I’d scold the sysadmin instead for not cofiguring critical systems in a secure way. Ulimit exists for a reason.

      • tetris11@lemmy.ml
        link
        fedilink
        arrow-up
        2
        ·
        6 hours ago

        Huh. I never made that connection before. I always thought ulimit was to prevent excessive disk writes or something

        • optional@sh.itjust.works
          link
          fedilink
          arrow-up
          2
          ·
          4 hours ago

          ulimit -H -u 10 will (hard)limit the current process (the shell) to 10 subprocesses. You can also use it to limit the number of open files etc.

          To globally configure that for a user/group you’d use /etc/security/limits.conf instead.

          If you want to prevent users from filling up the disk, take a look into quota.