Skip to content

Commit 0d6f7e5

Browse files
committed
Restore TTY mode on unclean shutdown (uncaught exception)
1 parent 6967e04 commit 0d6f7e5

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/Stdin.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ public function __construct(LoopInterface $loop)
3232
// Disable icanon (so we can fread each keypress) and echo (we'll do echoing here instead)
3333
shell_exec('stty -icanon -echo');
3434
}
35+
36+
// register shutdown function to restore TTY mode in case of unclean shutdown (uncaught exception)
37+
// this will not trigger on SIGKILL etc., but the terminal should take care of this
38+
register_shutdown_function(array($this, 'close'));
3539
}
3640

3741
public function close()

0 commit comments

Comments
 (0)