pipe.py 448 B

12345678910111213141516171819
  1. #! /usr/bin/env python3
  2. # Copyright (C) 2023 YAMAMOTO Takashi
  3. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. # This is a copy of https://github.com/yamt/toywasm/blob/master/test/pipe.py
  5. # keep stdout open until the peer closes it
  6. import sys
  7. import select
  8. p = select.poll()
  9. p.register(sys.stdout, select.POLLHUP)
  10. # http://gnats.netbsd.org/cgi-bin/query-pr-single.pl?number=57369
  11. while True:
  12. l = p.poll(1)
  13. if l:
  14. break