Last active
August 17, 2016 19:10
-
-
Save larryprice/f562f838ff84929c1619978a6404b8b6 to your computer and use it in GitHub Desktop.
Light script to demonstrate lxc.attach_wait hoarding stdin even after it's finished
This file contains 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
#!/usr/bin/env python3 | |
import lxc | |
import time | |
import os | |
CONTAINER_NAME='xenial' | |
CONTAINER_PATH='%s/.cache/libertine-container' % os.environ["HOME"] | |
def lxc_work(): | |
container = lxc.Container(CONTAINER_NAME, CONTAINER_PATH) | |
container.start() | |
container.attach_wait(lxc.attach_run_command, ['ls']) | |
def sleep_work(): | |
time.sleep(5) | |
print("Ctrl+C will attempt to stop the script during the next ~5 seconds") | |
sleep_work() | |
print("Running lxc command 'ls' in container '%s', please wait..." % CONTAINER_NAME) | |
lxc_work() | |
print("Ctrl+C should attempt to stop the script in the next ~5 seconds, but doesn't") | |
sleep_work() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment