• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

how dangerous is this

Journer

Banned
so i am taking my first c++ under unix class and i'm wondering what would happen if you ran this code:

#include <iostream>
#include <string>
using namespace std;
int main(){
string str;
int pid = fork();
int a=0;
while(pid!=0){
pid=fork();
str="g++ bigapp.ccp -o ";
char c=a;
str.insert(18,c);
system(str);
a++;
}
return 0;}

from the way i understand it, the code would keep creating new processes that compile the bigapp.ccp with a new name each time. if the application took a considerable amount of time to compile wouldnt this program eventually crash the PC because it would be running so many times and trying to compile each time. essentially it would try to do this forever right? since the pid will never be 0 again. or am i wrong?

i would have run it on the server we do our programming on but i was scared >.>
 
Most modern unix OSes have per-user process limits. If your system is properly configured, everyone else will be slightly annoyed, and you'll have to find a way to forcefully log yourself out / kill your processes.

edit: By the way, that's called a "fork bomb".
 
Originally posted by: CTho9305
Most modern unix OSes have per-user process limits. If your system is properly configured, everyone else will be slightly annoyed, and you'll have to find a way to forcefully log yourself out / kill your processes.

awww....i thought i was a l557 hax0r >_<!!!
 
Just write a simple loop. It'll slowly but surely bog down a system.

$int = 1
while($int != 0){
$int++;
print "Have a nice day";
}

Or...

int i;
i = 1;
while(i != 0){
i++;
}
 
Originally posted by: LoKe
Just write a simple loop. It'll slowly but surely bog down a system.

$int = 1
while($int != 0){
$int++;
print "Have a nice day";
}

Or...

int i;
i = 1;
while(i != 0){
i++;
}

Neither of those will do much unless you're on a single-CPU / single-core machine and your processes run at a higher priority than everybody else's. Those two loops are no different from running one instance of one of seti@home, folding@home, prime95, etc.
 
Wouldn't you also run into invalid characters eventually? Also, you're starting at 'a', which is a poor choice. 'A' is character 65 and 'a' is character 97, therefore you're skipping the entire uppercase section and even numbers. I don't really tinker with linux enough to know its restrictions on file names.

http://www.asciitable.com/ for a reference.
 
Originally posted by: CTho9305
Neither of those will do much unless you're on a single-CPU / single-core machine and your processes run at a higher priority than everybody else's. Those two loops are no different from running one instance of one of seti@home, folding@home, prime95, etc.

Run the script multiple times.
 
Originally posted by: LoKe
Originally posted by: CTho9305
Neither of those will do much unless you're on a single-CPU / single-core machine and your processes run at a higher priority than everybody else's. Those two loops are no different from running one instance of one of seti@home, folding@home, prime95, etc.

Run the script multiple times.

I suspect you haven't actually tried this.
 
Originally posted by: CTho9305
Originally posted by: LoKe
Originally posted by: CTho9305
Neither of those will do much unless you're on a single-CPU / single-core machine and your processes run at a higher priority than everybody else's. Those two loops are no different from running one instance of one of seti@home, folding@home, prime95, etc.

Run the script multiple times.

I suspect you haven't actually tried this.

I live in constant fear.
 
I remember back in first year college we did our programming off a citrix server.

They realized how bad of an idea that was, the year after we had our own private programming lab that was off the main network. At least once a day we'd have to get IT to shut down a process or even reboot one of the servers. This was vB at the time, so thats slow on its own. a simple increment loop written in vB will pretty much bog down the server. Funny thing is, most of the time it was not intentional.
 
haha...its been three weeks of this class an so far i've learned how to DOS a system and spam the world from a fake email...mwuahahaha i :heart: c++
 
Back
Top