From 9cf4a32fb96810e2760db3649322f864e0913606 Mon Sep 17 00:00:00 2001
From: sfanxiang <sfanxiang@gmail.com>
Date: Sat, 13 Jan 2018 12:06:33 +0000
Subject: port to Haiku


diff --git a/src/bin/common/getpw.cpp b/src/bin/common/getpw.cpp
index 938abd5..584ce40 100644
--- a/src/bin/common/getpw.cpp
+++ b/src/bin/common/getpw.cpp
@@ -86,6 +86,8 @@ int getpin(const char* prompt, char* buffer, size_t size)
 	// Update the mode flags
 	new_attr.c_lflag &= ~ICANON;
 	new_attr.c_lflag &= ~ECHO;
+	new_attr.c_cc[VMIN] = 1;
+	new_attr.c_cc[VTIME] = 0;
 
 	// Handle the SIGINT signal
 	signo = 0;
@@ -100,7 +102,7 @@ int getpin(const char* prompt, char* buffer, size_t size)
         }
 
 	// Set the new terminal attributes
-	if (tcsetattr(STDIN_FILENO, 0, &new_attr) < 0)
+	if (tcsetattr(STDIN_FILENO, TCSAFLUSH, &new_attr) < 0)
 		return -1;
 #endif
 
@@ -126,7 +128,7 @@ int getpin(const char* prompt, char* buffer, size_t size)
 		return -1;
 #else
 	// Restore terminal
-	if (tcsetattr(STDIN_FILENO, 0, &old_attr) < 0)
+	if (tcsetattr(STDIN_FILENO, TCSAFLUSH, &old_attr) < 0)
 		return -1;
 
 	// Restore the signal
-- 
2.15.0

