Hi ...
i am doin my B.E in computer science amd i was asked to write a programme ...
can anyone help me write a c program that can hang the system ... and can u also tel me how to set it right again...:icon_neutral: and can u tel me how to use the debug option ... pl pl. plzzzzzzzz......

Comments
Learn to spell and do your own homework.

Hi ...
i am doin my B.E in computer science amd i was asked to write a programme ...
can anyone help me write a c program that can hang the system ... and can u also tel me how to set it right again...:icon_neutral: and can u tel me how to use the debug option ... pl pl. plzzzzzzzz......

The operative phrase here is "i was asked to write a programme ..." meaning you...So what do you have so far?

Edited 6 Years Ago by gerard4143: n/a

Hi ...
i am doin my B.E in computer science amd i was asked to write a programme ...
can anyone help me write a c program that can hang the system ... and can u also tel me how to set it right again...:icon_neutral: and can u tel me how to use the debug option ... pl pl. plzzzzzzzz......

See... Jevintha .. I think you are new to programming forums...If you want to expect some answers post your existing code...And ask your queries or problems in that code...

Secondly, I don't think that " Hi... " is a descriptive title for your question...

Otherwise , You'll not get a valid response...

good morning ... thanks for your response ...
can you plz tell me what is system hanging ...
can an infiniet loop be called a system hanging ....
what exactly is system hanging in c ...
i did nt get this right ..

The operative phrase here is "i was asked to write a programme ..." meaning you...So what do you have so far?

can u pl ,let me know what is system hanging in C ..
actually can an infinite loop be called a hanging program..

The best person to ask for the definition of "system hanging" would be the one that gave you the assignment. There's some ambiguity to the term.

I think the whole idea seems suspect but maybe it's me.

can u pl ,let me know what is system hanging in C ..
actually can an infinite loop be called a hanging program..

Yes it can be done with an infinite loop but only in WINDOWS 98 and prior..:-/..

Rather, you should try different methods ....

Experiment yourself first...and then ask....,:?:
There's no harm in that is it.....:icon_exclaim:

Hi ...
i am doin my B.E in computer science amd i was asked to write a programme ...
can anyone help me write a c program that can hang the system ... and can u also tel me how to set it right again...:icon_neutral: and can u tel me how to use the debug option ... pl pl. plzzzzzzzz......

I thought about your idea... Found it interesting and made it ....
Here's a system hanging code for *nix type systems...

// This program creates unlimited Processes and ultimately the system results in hang
#include<stdio.h>
#include<unistd.h>
#include<stdlib.h>

int main()
{
	int i;
	for(i=0;i<=100;i++)
	{
		pid_t pid;
		pid = fork();
	
		if(pid!=0)
		{
			printf("Parent process %d\n",getpid());
			wait(NULL);
		}
		else if(pid==0)
		{
			printf("Child process!! : %d\n",getpid());
	
			pid=fork();
			if(pid!=0)
			{
				printf("This is a child->parent process!! : %d of %d\n",getpid(),getppid());
			}
			else if(pid==0)
			{
				printf("This is a child->child process : %d of %d\n",getpid(),getppid());
	
				pid=fork();
				if(pid!=0)
				{
					printf("This is a child->child->parent %d process of %d!!\n",getpid(),getppid());
				}
				else if(pid==0)
				{
					printf("This is a child->child->child process : %d of %d\n",getpid(),getppid());	
				}	
			}
		}
	}

	return(0);
}

I thought about your idea... Found it interesting and made it ....
Here's a system hanging code for *nix type systems...

// This program creates unlimited Processes and ultimately the system results in hang
#include<stdio.h>
#include<unistd.h>
#include<stdlib.h>

int main()
{
	int i;
	for(i=0;i<=100;i++)
	{
		pid_t pid;
		pid = fork();
	
		if(pid!=0)
		{
			printf("Parent process %d\n",getpid());
			wait(NULL);
		}
		else if(pid==0)
		{
			printf("Child process!! : %d\n",getpid());
	
			pid=fork();
			if(pid!=0)
			{
				printf("This is a child->parent process!! : %d of %d\n",getpid(),getppid());
			}
			else if(pid==0)
			{
				printf("This is a child->child process : %d of %d\n",getpid(),getppid());
	
				pid=fork();
				if(pid!=0)
				{
					printf("This is a child->child->parent %d process of %d!!\n",getpid(),getppid());
				}
				else if(pid==0)
				{
					printf("This is a child->child->child process : %d of %d\n",getpid(),getppid());	
				}	
			}
		}
	}

	return(0);
}

Change the very first line to:-

// This program creates many Processes and ultimately the system results in hang

Change the very first line to:-

// This program creates many Processes and ultimately the system results in hang

lol leave the ethics he has a grammar mistake.

I don't know what good can come out of this! Still speaking of lionanees's bizarre technique, just put that in a function which call's itself recursively. :-\
Sigh!

wen ppl in this community voted this thread down pplk lik u are still thr to try things out .. thanks a million 4 that

Comments
You've got a full keyboard and plenty of space to write what you mean. This isn't some 160 char limit via SMS.

I suspect that there is an error with this assignment, much like what jonsca said. Very suspicious... Anyways, the code lionaneesh has posted only works on *nix systems, and I suppose you are one of the 90% of 6 billion people who use bill's SUX system. Anyways, that is very unlikely to be done. Infinite loops only result in a single cmd window hanging. Unless your OS IS a single cmd window, it won't hang anytime soon. Unless you really need to do so, DON'T use this.

#include "stdio.h"
#include "stdlib.h"

main()
{
while(true)
{
system("cmd.exe");
}
}

I think you are forking more threads than you intend. You realize that in each loop, you wait for the first thread, but fork three more, which all complete, and go back into the loop ?
That's 3 * 3 * 3 *... a hundred times, or, 3 to the hundredth power.
The system dies from handle starvation, massive memory swaps and context switching.
You need to wait on all but one thread.

I think you are forking more threads than you intend. You realize that in each loop, you wait for the first thread, but fork three more, which all complete, and go back into the loop ?
That's 3 * 3 * 3 *... a hundred times, or, 3 to the hundredth power.
The system dies from handle starvation, massive memory swaps and context switching.
You need to wait on all but one thread.

Pretty sure that's the point.

I could be wrong, but it sounds to me like he wants everyone to do his work for him and explain it to him. If he was in class, he should know what this is by definition at least. And yeah, posting his own code would have helped this situation.

what kind of professor teaches his students how to write a fork bomb !?

either a really "cool" one, or an ethically challenged one.

This article has been dead for over six months. Start a new discussion instead.