MCPcopy Create free account
hub / github.com/canonical/cloud-init / close_stdin

Function close_stdin

cloudinit/cmd/main.py:147–158  ·  view source on GitHub ↗

reopen stdin as /dev/null to ensure no side effects logger: a function for logging messages

(logger: Callable[[str], None] = LOG.debug)

Source from the content-addressed store, hash-verified

145
146@performance.timed("Closing stdin")
147def 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
161def extract_fns(args):

Callers 3

main_initFunction · 0.85
main_modulesFunction · 0.85
main_singleFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected