Ask Your Question
0

How does Linux handle my programs?

asked 2016-10-19 07:42:55 -0600

Tijuk gravatar image

Hey guys, Im new to Linux, installed it just this past week (after like 2 days of complete struggle hahaha) Im on Fedora 24.

On my Programming Classes, all I do on Linux's Terminal, is compile stuff, and run .c codes... but I want to know, what exacly goes inside Linux when that happens...

I mean, I can compile and execute any sort of program? Even if it is dangerous for my computer? or does Linux/Fedora have some sort of safety check of some sort... I dont know if I made myself clear xD

and example, if I tried to run this programa here:

#include <stdio.h>
#include <unistd.h>

void forknator()
{
    if(fork() < 0)
    {
        return;
    }
    forknator();
}

int main()
{
    while(1)
    {
        forknator();
    }
    return 0;
}

I would be creating an endless number of processes... Honestly, I'm not exacly sure what creating an enormous amount of process would actually do to my PC (crash, slow, etc, idk...) but I know this program would be bad news for it... Would I even be able to run this program? Or I would get some sort of check? If I did run it... would I get any warnings? Would my OS do something to it? Or let it create new processes till the end of times??

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
2

answered 2016-10-19 13:05:42 -0600

fcomida gravatar image

Try $ulimit -a in a terminal. Regular users have limits over usage of many type of resources (num of processes, files opened, etc.) The ultimate limit is dictated by the hardware (RAM size + SWAP size for processes)....so why don't you try running your program (i bet your system will become really slow)?

edit flag offensive delete link more
1

answered 2016-10-19 14:54:38 -0600

sideburns gravatar image

Welcome to ask.fedora, and congratulations: you've just re-invented the fork bomb. No, it won't create an endless number of processes because, as pointed out by fcomida, there's a limit to how many processes any one user can create. However, it will rapidly slow your machine down to a crawl, and you may have trouble cleaning things up without rebooting. My suggestion is that if you want to try it, do so in a terminal, not from a CLI because if all else fails, you can always kill them by closing the terminal.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2016-10-19 07:42:55 -0600

Seen: 83 times

Last updated: Oct 19 '16