Last active
November 14, 2018 15:37
-
-
Save jschwinger233/a76dd655a0b793d21fc25a57c79b8d01 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
| 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