python - pwntools [Errno 24] Too many open files [-] Starting local process - Stack Overflow

admin2025-04-17  4

I'm having an issue with some code I'm writing. I'm getting this pwntools error about too many files being open. My code looks like.

    for a in range(0,2**3360):
        try:
            with open("output.txt", "a") as f:
                p =process(os.getcwd()+ "/flag",stdout=f)
                f.write(f'L:{a}\na')
                sleep(0.05)
                p.wait_for_close()
                while(p.poll()!=0):
                    continue
            f.close()

This unfortunately this code causes a too many files open error. How can I make sure the io files and such are closed so its safe to continue starting processes? The sleep and p.wait_for_close() and p.poll in while loop were attempts.

转载请注明原文地址:http://anycun.com/QandA/1744825221a88136.html