Understanding the fork system call in Unix
While we&#x27;re on the topic of calling fork and overloading servers to the point that they can&#x27;t establish database connections or serve web pages, I&#x27;d like to point out that forking another process is an astronomically EXPENSIVE and WASTEFUL way of performing simple arithmetic and string manipulation.<p>Please stop wasting electricity and time by writing shell scripts that fork processes to do ridiculously simple things like calling &quot;bc&quot; to add two numbers or &quot;sed&quot; to perform simple string manipulation, since your computer has a &quot;mul&quot; instruction that doesn&#x27;t require millions of instructions and bytes of memory and disk accesses to perform.<p>It&#x27;s like using Bitcoin to pay for a stick of gum.<p><a href="https:&#x2F;&#x2F;www.quora.com&#x2F;How-much-energy-does-it-take-to-make-a-Bitcoin-transaction" rel="nofollow">https:&#x2F;&#x2F;www.quora.com&#x2F;How-much-energy-does-it-take-to-make-a...</a><p>&gt;According to Digiconmist, each bitcoin transaction took 215 kWh. Whereas an average Indian household consume : 90 kWh per month. It sums up that, each bitcoin consumption can power a average indian household for 2.5 months probably. The average electricity cost in India is 5 rupees per kwh.<p>It&#x27;s like rolling coal because you want to trigger the libs.<p><a href="https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=fkmLf5OXxz0" rel="nofollow">https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=fkmLf5OXxz0</a><p>Stop and think before you write that shell script. It&#x27;s not going to take you any more time to write it in Python, and then you won&#x27;t be so shocked and surprised and totally fucked when you realize later that you need to add more features and make it more complicated than you originally though it would need to be in the first place.<p>It just boggles my mind that some people have such a hard time understanding how spectacularly inefficient shell scripts are, on top of how horrible to write, read, understand and maintain they are.<p><a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=19886164" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=19886164</a>