Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
M
Magisk
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Magisk
Commits
34bcb1dd
Commit
34bcb1dd
authored
Jul 23, 2021
by
vvb2060
Committed by
John Wu
Aug 29, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix line editing on Android 8.0+
parent
117d1ed0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
17 deletions
+14
-17
pts.cpp
native/jni/su/pts.cpp
+14
-17
No files found.
native/jni/su/pts.cpp
View file @
34bcb1dd
...
@@ -127,27 +127,22 @@ static int stdin_is_raw = 0;
...
@@ -127,27 +127,22 @@ static int stdin_is_raw = 0;
* on failure -1, and errno is set
* on failure -1, and errno is set
* on success 0
* on success 0
*/
*/
int
set_stdin_raw
(
void
)
{
int
set_stdin_raw
()
{
struct
termios
new_termios
;
struct
termios
termios
{}
;
// Save the current stdin termios
if
(
tcgetattr
(
STDIN_FILENO
,
&
termios
)
<
0
)
{
if
(
tcgetattr
(
STDIN_FILENO
,
&
old_stdin
)
<
0
)
{
return
-
1
;
return
-
1
;
}
}
// Start from the current settings
old_stdin
=
termios
;
new_termios
=
old_stdin
;
// Make the terminal like an SSH or telnet client
cfmakeraw
(
&
termios
);
new_termios
.
c_iflag
|=
IGNPAR
;
new_termios
.
c_iflag
&=
~
(
ISTRIP
|
INLCR
|
IGNCR
|
ICRNL
|
IXON
|
IXANY
|
IXOFF
);
new_termios
.
c_lflag
&=
~
(
ISIG
|
ICANON
|
ECHO
|
ECHOE
|
ECHOK
|
ECHONL
);
new_termios
.
c_oflag
&=
~
OPOST
;
new_termios
.
c_cc
[
VMIN
]
=
1
;
new_termios
.
c_cc
[
VTIME
]
=
0
;
if
(
tcsetattr
(
STDIN_FILENO
,
TCSAFLUSH
,
&
new_termios
)
<
0
)
{
if
(
tcsetattr
(
STDIN_FILENO
,
TCSAFLUSH
,
&
termios
)
<
0
)
{
return
-
1
;
// https://blog.zhanghai.me/fixing-line-editing-on-android-8-0/
if
(
tcsetattr
(
STDIN_FILENO
,
TCSADRAIN
,
&
termios
)
<
0
)
{
return
-
1
;
}
}
}
stdin_is_raw
=
1
;
stdin_is_raw
=
1
;
...
@@ -168,11 +163,13 @@ int set_stdin_raw(void) {
...
@@ -168,11 +163,13 @@ int set_stdin_raw(void) {
* on failure, -1 and errno is set
* on failure, -1 and errno is set
* on success, 0
* on success, 0
*/
*/
int
restore_stdin
(
void
)
{
int
restore_stdin
()
{
if
(
!
stdin_is_raw
)
return
0
;
if
(
!
stdin_is_raw
)
return
0
;
if
(
tcsetattr
(
STDIN_FILENO
,
TCSAFLUSH
,
&
old_stdin
)
<
0
)
{
if
(
tcsetattr
(
STDIN_FILENO
,
TCSAFLUSH
,
&
old_stdin
)
<
0
)
{
return
-
1
;
if
(
tcsetattr
(
STDIN_FILENO
,
TCSADRAIN
,
&
old_stdin
)
<
0
)
{
return
-
1
;
}
}
}
stdin_is_raw
=
0
;
stdin_is_raw
=
0
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment