Skip to content

Instantly share code, notes, and snippets.

@tonyskapunk
Last active June 13, 2018 22:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tonyskapunk/ebf3cc3d09555a55b48ffd43b4ab255f to your computer and use it in GitHub Desktop.
Save tonyskapunk/ebf3cc3d09555a55b48ffd43b4ab255f to your computer and use it in GitHub Desktop.
roulette
#!/usr/bin/python
from random import choice
from signal import Signals
from os import listdir, kill
def main():
while true:
# Get random a signal
lucky_signal = choice(list(Signals))
# Get a random pid
proc = listdir('/proc')
index_one = proc.index('1')
pids = proc[60:]
lucky_pid = choice(pids)
if lucky_signal.value == lucky_pid:
break
print(f'Sending SIGNAL:{lucky_signal} to PID: {lucky_pid}')
kill(lucky_pid, lucky_signal)
if __name__ == "__main__":
main()
while true; do
if [[ $(( ${RANDOM} % 9 + 1 )) -eq $(( ${RANDOM} % 9 + 1 )) ]]; then
break
fi
sudo kill -$(( ${RANDOM} % 9 + 1 )) $(( ${RANDOM} % 9 + 1 )) &>/dev/null
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment