Find the answer to your Linux question:
Results 1 to 6 of 6
Alright, i don't know what i did but i started like a 1000 processes and I dont know how. So i have a bash shell script that had a bunch ...
  1. #1
    Just Joined!
    Join Date
    Sep 2005
    Posts
    99

    functions and processes in unix

    Alright, i don't know what i did but i started like a 1000 processes and I dont know how. So i have a bash shell script that had a bunch of code all over the place so i wanted to make it look nicer so i divided it into functions and then when i need to call the functions i do. There are like maybe 10 or so functions. I didn't change any of the code i just re arranged it. When i ran it to test it is said that a file could not be found and was in like an infinite loop. Then, i tried ctrl + c that paused it and brought the prompt back up for a second and then it continued. Then i tried ctrl + d that stopped it for a moment brought the prompt back up and then it started again. I know when unix creates a new process it forks. Is there a command that forks or something, or does it fork every time a function is called or something? Why would it fork over 900 times when i tried to run the script? It's a pretty long script, but i can post it if you want. Also, now that all these processes are there is there a really fast way to stop them all without having to type kill -9 and then the process id 900 times?

  2. #2
    Just Joined!
    Join Date
    May 2005
    Posts
    48
    Hello
    Take a breather ...
    Try your damndest to get organized with proper coding
    with spacing and comments
    look here at the examples.
    make many printf or echo statements to see exactly where you are in the program and the status of all the variables.
    Maybe even comment out all the functions and solve them one by one.
    Or even break statements at intervals.
    Or even break the program into smaller test cases and edit accordingly.

    IBM has some quide lines
    here too
    hth

  3. #3
    Linux Enthusiast likwid's Avatar
    Join Date
    Dec 2006
    Location
    MA
    Posts
    649
    Code:
    pgrep processname | xargs kill -9

  4. #4
    Just Joined!
    Join Date
    Sep 2005
    Posts
    99
    yep did that i think it gets rid of some but then it comes up with a bunch of process not found messages and then when i look at how many processes are running its still over 900 i think its still creating them actually somehow. Is that possible?

  5. #5
    Just Joined!
    Join Date
    Sep 2005
    Posts
    99
    how do i look at the processes running in the back ground because if that one column in the ps -ef is showing when the process was created then the processes are definetly still being created. And i'm thinking if i could find the process that is making them and stop that then it will be fixed.

  6. #6
    Linux Enthusiast likwid's Avatar
    Join Date
    Dec 2006
    Location
    MA
    Posts
    649
    You want to kill the PPID then, which is the parent process id.

Posting Permissions

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