8000 Fix dev run container exiting from raw mode (#10646) · localstack/localstack@03c220a · GitHub
[go: up one dir, main page]

Skip to content

Commit 03c220a

Browse files
authored
Fix dev run container exiting from raw mode (#10646)
1 parent e7b0bad commit 03c220a

File tree

1 file changed

+1
-36
lines changed

1 file changed

+1
-36
lines changed

localstack/utils/run.py

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -158,42 +158,7 @@ def run_interactive(command: List[str]):
158158
159159
:param command: the command to pass to subprocess.Popen
160160
"""
161-
# save original tty setting then set it to raw mode
162-
import pty
163-
import termios
164-
import tty
165-
166-
old_tty = termios.tcgetattr(sys.stdin)
167-
tty.setraw(sys.stdin.fileno())
168-
169-
# open pseudo-terminal to interact with subprocess
170-
master_fd, slave_fd = pty.openpty()
171-
172-
try:
173-
# use os.setsid() make it run in a new process group, or bash job control will not be enabled
174-
p = subprocess.Popen(
175-
command,
176-
preexec_fn=os.setsid,
177-
stdin=slave_fd,
178-
stdout=slave_fd,
179-
stderr=slave_fd,
180-
universal_newlines=True,
181-
)
182-
183-
while p.poll() is None:
184-
r, w, e = select.select([sys.stdin, master_fd], [], [])
185-
if sys.stdin in r:
186-
d = os.read(sys.stdin.fileno(), 10240)
187-
os.write(master_fd, d)
188-
if d == b"\x04":
189-
break
190-
elif master_fd in r:
191-
o = os.read(master_fd, 10240)
192-
if o:
193-
os.write(sys.stdout.fileno(), o)
194-
finally:
195-
# restore tty settings back
196-
termios.tcsetattr(sys.stdin, termios.TCSADRAIN, old_tty)
161+
subprocess.check_call(command)
197162

198163

199164
def is_command_available(cmd: str) -> bool:

0 commit comments

Comments
 (0)
0