python - Dynamically name processes -
is possible program create dynamically name processes starts? consider famous fork bomb code:
:(){ :|:& };:
or
import os while os.fork() or true: os.fork()
would possible let generate new random process name every time executes? make lot harder rid of. doesn't have in perl or python, i'd love see examples in other languages too.
it possible set process name, capability varies os os. in perl, can assign $0
variable, changes current process name:
for $i (1 .. 5) { fork && next; $0 = "foobar: $i"; sleep 5; exit; } print grep /foobar/, `ps aux`;
which produces output:
1000 1231 0.0 0.0 7836 552 pts/5 s+ 13:32 0:00 foobar: 1 1000 1232 0.0 0.0 7836 552 pts/5 s+ 13:32 0:00 foobar: 2 1000 1233 0.0 0.0 7836 552 pts/5 s+ 13:32 0:00 foobar: 3 1000 1235 0.0 0.0 7836 552 pts/5 s+ 13:32 0:00 foobar: 4 1000 1236 0.0 0.0 7836 552 pts/5 s+ 13:32 0:00 foobar: 5
or similar. not know how done, shell , python should have similar functionality.
Comments
Post a Comment