Bash/Shell script - make it loop forever??[SOLVED]

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Post Reply
Message
Author
User avatar
greengeek
Posts: 5789
Joined: Tue 20 Jul 2010, 09:34
Location: Republic of Novo Zelande

#16 Post by greengeek »

SFR wrote:Basically it's a nice looking one-liner, which multiplies itself (or rather its own process) ad infinitum, what makes system completely freezed.
Sadly, Puppy isn't immune for that kind of attack..!
It's very handy for me to know that I need to take care to avoid such risks. I'm always keen to tinker and "have a bash" so I would've dived in and locked up my system for sure... :-) Wiki suggests this as a means of prevention:
As a fork bomb's mode of operation is entirely encapsulated by creating new processes, one way of preventing a fork bomb from severely affecting the entire system is to limit the maximum number of processes that a single user may own.
I wonder if this might be possible on Puppy.

BTW - My reason for wanting these scripts to help with mouse movement is to allow an inexperienced or physically challenged user to easily select between a limited number of mousepointer_position_choices. That way they can have some degree of functionality by having a "mouseclick" button, but no actual ability to move the mouse anywhere I don't want it to go.

User avatar
SFR
Posts: 1800
Joined: Wed 26 Oct 2011, 21:52

#17 Post by SFR »

greengeek wrote:
SFR wrote:infinite loop, but deprived of deadly "fork" mechanism) can be utilized as well:

Code: Select all

:(){ echo "Loop..."; sleep 1; :; };:
But of course this is not a good idea to have something like that in your code, so consider this as a "tip of the day".
Do you mean that it's not a good idea because it's so easy to get it wrong (and include a recursive fork by mistake)?
That too, but primarily, because 'while...' or 'until...' are most simple/common/readable methods.
But it may be useful, for example, if you'd like to deliberately obfuscate the code.
greengeek wrote:Wiki suggests this as a means of prevention:
As a fork bomb's mode of operation is entirely encapsulated by creating new processes, one way of preventing a fork bomb from severely affecting the entire system is to limit the maximum number of processes that a single user may own.
I wonder if this might be possible on Puppy.
Hard to say...
# ulimit -a | grep "max user processes"
max user processes (-u) 30948
#
shows that max. number of processes is limited, but it doesn't seem to work (maybe it doesn't affect root account?).

Greetings!
[color=red][size=75][O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource[/size][/color]
[b][color=green]Omnia mea mecum porto.[/color][/b]

User avatar
greengeek
Posts: 5789
Joined: Tue 20 Jul 2010, 09:34
Location: Republic of Novo Zelande

#18 Post by greengeek »

This thread morphed into an expanded topic tracing the development of SFRs "OneSwitch" pet for disabled users. New thread can be found here:
http://murga-linux.com/puppy/viewtopic.php?t=87418

User avatar
greengeek
Posts: 5789
Joined: Tue 20 Jul 2010, 09:34
Location: Republic of Novo Zelande

#19 Post by greengeek »

SFR wrote:Hard to say...
# ulimit -a | grep "max user processes"
max user processes (-u) 30948
#
shows that max. number of processes is limited, but it doesn't seem to work (maybe it doesn't affect root account?).
Greetings!
On a different thread "scientist" has been trying the following:
This works and prevents root user from starting more than 50 processes.

Code: Select all

root   hard    nproc           50
I haven't tried it yet but thought I would post it.
The other thread is:
http://www.murga-linux.com/puppy/viewtopic.php?t=100634

User avatar
L18L
Posts: 3479
Joined: Sat 19 Jun 2010, 18:56
Location: www.eussenheim.de/

#20 Post by L18L »

greengeek wrote:On a different thread "scientist" has been trying the following:
This works and prevents root user from starting more than 50 processes.

Code: Select all

root   hard    nproc           50
I haven't tried it yet but thought I would post it.
I have tried it:

Code: Select all

# root   hard    nproc           50
bash: root: command not found
# 
:wink:

Post Reply