Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

How to check forks (& how many) from terminal?

New to Debian (Or Linux in general)? Ask your questions here!
Post Reply
Message
Author
bkpsusmitaa
Posts: 485
Joined: 2009-07-04 06:32
Location: Home: Barrackpore and Mysore
Has thanked: 5 times

How to check forks (& how many) from terminal?

#1 Post by bkpsusmitaa »

May please the script below be checked:

Code: Select all

    #!/bin/bash
    echo "Usage: ./ssvr.sh ssvr.sh"
    done=0
    i=0
    while true
    do
    expr $(( i = i + 1 ))
    read -p "To stop press n and Enter : " -t 2 INPOOT
    xset dpms force off
    sleep 12
    if [ "$INPOOT" = "n" ]; then
    echo "Ending..."
    echo
    exit 0
    fi
    done
I am concerned that each loop of while...do could be creating another fork with the command "xset dpms force off".
But the situation also provides a scope for learning.
Which is why my question arises.
Could I please be helped in this regard?
Freedom is impossible to conceive.
Books that help:
Dale Carnegie's How To Win Friends And Influence People and Emilie Post's Etiquette In Society, In Business, In Politics, And At Home

peter_irich
Posts: 1403
Joined: 2009-09-10 20:15
Location: Saint-Petersburg, Russian Federation
Been thanked: 11 times

Re: How to check forks (& how many) from terminal?

#2 Post by peter_irich »

I don't understend in what problem is, but such script seems me better:

Code: Select all

#!/bin/bash

echo "Usage: ./ssvr.sh ssvr.sh"
#done=0
i=0
while [ 1 ] ; do
let i++
read -p "To stop press n and Enter : " -t 2 INPOOT
xset dpms force off
sleep 12
/bin/echo -e "\r"
if [ "$INPOOT" = "n" ]; then
echo "Ending..."
echo
exit 0
fi
done
Peter.

bkpsusmitaa
Posts: 485
Joined: 2009-07-04 06:32
Location: Home: Barrackpore and Mysore
Has thanked: 5 times

Re: How to check forks (& how many) from terminal?

#3 Post by bkpsusmitaa »

One poster privately messaged me a resource. I couldn't PM him, as
Some users couldn’t be added as they have disabled private message receipt.
I can't also name him on the forum as he desired privacy. His resource isn't copyright or private though. I shall post the link after I have gone through it and found it serving my purpose. But I had PMed him as he deserves thanks for posting a reference/link.

Thank you, Mr. Irich. Now consider your better script.

What is the role of: /bin/echo -e "\r" here, other than better presentability, could you kindly explain please? I am not challenging you. Want to know your viewpoint.

The code with \r enters a return. And the command echo is in the path. So why /usr/bin/echo?

Now may the line "xautolock -time 1 -locker "./ssvr.sh" be executed in place of simply the script ssvr.sh.

Then please check and inform how to check forking in such a scenario, and pause the next fork until the first pipe is finished.
Freedom is impossible to conceive.
Books that help:
Dale Carnegie's How To Win Friends And Influence People and Emilie Post's Etiquette In Society, In Business, In Politics, And At Home

Post Reply