reopen stdin as /dev/null to ensure no side effects logger: a function for logging messages
(logger: Callable[[str], None] = LOG.debug)
| 145 | |
| 146 | @performance.timed("Closing stdin") |
| 147 | def close_stdin(logger: Callable[[str], None] = LOG.debug): |
| 148 | """ |
| 149 | reopen stdin as /dev/null to ensure no side effects |
| 150 | |
| 151 | logger: a function for logging messages |
| 152 | """ |
| 153 | if not os.isatty(sys.stdin.fileno()): |
| 154 | logger("Closing stdin") |
| 155 | with open(os.devnull) as fp: |
| 156 | os.dup2(fp.fileno(), sys.stdin.fileno()) |
| 157 | else: |
| 158 | logger("Not closing stdin, stdin is a tty.") |
| 159 | |
| 160 | |
| 161 | def extract_fns(args): |
no outgoing calls
no test coverage detected