Skip to content

Instantly share code, notes, and snippets.

@jschwinger233
Last active November 14, 2018 15:37
Show Gist options
  • Select an option

  • Save jschwinger233/a76dd655a0b793d21fc25a57c79b8d01 to your computer and use it in GitHub Desktop.

Select an option

Save jschwinger233/a76dd655a0b793d21fc25a57c79b8d01 to your computer and use it in GitHub Desktop.
import os
import sys
def main():
line = 'x' * (int(sys.argv[1]) - 1) + '\n'
buf_mode = {'--nbf': 0, '--lbf': 1, '--fbf': 2}[sys.argv[2]]
for _ in range(10):
pid = os.fork()
if pid == 0:
record(line, buf_mode)
sys.exit()
else:
continue
for _ in range(10):
os.wait()
def record(line, buf_mode):
with open('./out.txt', 'a', buffering=buf_mode) as f:
for _ in range(1000):
f.write(line)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment