Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
com.ccwangluo.accelerator
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sheteng
com.ccwangluo.accelerator
Commits
7a52f700
Commit
7a52f700
authored
Dec 19, 2012
by
Max Lv
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
disable redirect for commands
parent
634e077b
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
26 additions
and
16 deletions
+26
-16
jni/termExec.cpp
jni/termExec.cpp
+21
-11
libs/armeabi/libexec.so
libs/armeabi/libexec.so
+0
-0
src/com/github/shadowsocks/Exec.java
src/com/github/shadowsocks/Exec.java
+2
-1
src/com/github/shadowsocks/Utils.java
src/com/github/shadowsocks/Utils.java
+3
-4
No files found.
jni/termExec.cpp
View file @
7a52f700
...
...
@@ -99,7 +99,7 @@ static int throwOutOfMemoryError(JNIEnv *env, const char *message)
return
env
->
ThrowNew
(
exClass
,
message
);
}
static
int
create_subprocess
(
const
char
*
cmd
,
char
*
const
argv
[],
static
int
create_subprocess
(
const
int
rdt
,
const
char
*
cmd
,
char
*
const
argv
[],
char
*
const
envp
[],
const
char
*
scripts
,
int
*
pProcessId
)
{
pid_t
pid
;
...
...
@@ -107,7 +107,10 @@ static int create_subprocess(const char *cmd, char *const argv[],
int
pfds2
[
2
];
pipe
(
pfds
);
pipe
(
pfds2
);
if
(
rdt
)
{
pipe
(
pfds2
);
}
pid
=
fork
();
...
...
@@ -127,9 +130,13 @@ static int create_subprocess(const char *cmd, char *const argv[],
dup2
(
pfds
[
0
],
0
);
close
(
pfds
[
1
]);
dup2
(
pfds2
[
1
],
1
);
dup2
(
pfds2
[
1
],
2
);
close
(
pfds2
[
0
]);
if
(
rdt
)
{
close
(
1
);
close
(
2
);
dup2
(
pfds2
[
1
],
1
);
dup2
(
pfds2
[
1
],
2
);
close
(
pfds2
[
0
]);
}
execv
(
cmd
,
argv
);
...
...
@@ -144,15 +151,18 @@ static int create_subprocess(const char *cmd, char *const argv[],
close
(
pfds
[
0
]);
write
(
pfds
[
1
],
scripts
,
strlen
(
scripts
)
+
1
);
close
(
pfds2
[
1
]);
return
pfds2
[
0
];
if
(
rdt
)
{
close
(
pfds2
[
1
]);
return
pfds2
[
0
];
}
else
{
return
-
1
;
}
}
}
static
jobject
android_os_Exec_createSubProcess
(
JNIEnv
*
env
,
jobject
clazz
,
jstring
cmd
,
jobjectArray
args
,
jobjectArray
envVars
,
jstring
scripts
,
j
int
rdt
,
j
string
cmd
,
jobjectArray
args
,
jobjectArray
envVars
,
jstring
scripts
,
jintArray
processIdArray
)
{
const
jchar
*
str
=
cmd
?
env
->
GetStringCritical
(
cmd
,
0
)
:
0
;
...
...
@@ -215,7 +225,7 @@ static jobject android_os_Exec_createSubProcess(JNIEnv *env, jobject clazz,
}
int
procId
;
int
ptm
=
create_subprocess
(
cmd_8
.
string
(),
argv
,
envp
,
scripts_8
.
string
(),
int
ptm
=
create_subprocess
(
rdt
,
cmd_8
.
string
(),
argv
,
envp
,
scripts_8
.
string
(),
&
procId
);
if
(
argv
)
{
...
...
@@ -324,7 +334,7 @@ static int register_FileDescriptor(JNIEnv *env)
static
const
char
*
classPathName
=
"com/github/shadowsocks/Exec"
;
static
JNINativeMethod
method_table
[]
=
{
{
"createSubprocess"
,
"(Ljava/lang/String;[Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;[I)Ljava/io/FileDescriptor;"
,
{
"createSubprocess"
,
"(
I
Ljava/lang/String;[Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;[I)Ljava/io/FileDescriptor;"
,
(
void
*
)
android_os_Exec_createSubProcess
},
{
"waitFor"
,
"(I)I"
,
(
void
*
)
android_os_Exec_waitFor
},
...
...
libs/armeabi/libexec.so
View file @
7a52f700
No preview for this file type
src/com/github/shadowsocks/Exec.java
View file @
7a52f700
...
...
@@ -43,6 +43,7 @@ public class Exec {
* Callers are responsible for calling Exec.close() on the returned file
* descriptor.
*
* @param rdt Whether redirect stdout and stderr
* @param cmd The command to execute.
* @param args An array of arguments to the command.
* @param envVars An array of strings of the form "VAR=value" to be added to the
...
...
@@ -52,7 +53,7 @@ public class Exec {
* process will be written.
* @return File descriptor
*/
public
static
native
FileDescriptor
createSubprocess
(
String
cmd
,
public
static
native
FileDescriptor
createSubprocess
(
int
rdt
,
String
cmd
,
String
[]
args
,
String
[]
envVars
,
String
scripts
,
int
[]
processId
);
...
...
src/com/github/shadowsocks/Utils.java
View file @
7a52f700
...
...
@@ -44,7 +44,7 @@ public class Utils {
String
arg0
=
argList
.
get
(
0
);
String
[]
args
=
argList
.
toArray
(
new
String
[
1
]);
return
Exec
.
createSubprocess
(
arg0
,
args
,
null
,
return
Exec
.
createSubprocess
(
result
!=
null
?
1
:
0
,
arg0
,
args
,
null
,
scripts
+
"\nexit\n"
,
processId
);
}
...
...
@@ -112,7 +112,7 @@ public class Utils {
pipe
=
createSubprocess
(
pid
,
getShell
());
}
if
(
pipe
==
null
)
return
;
if
(
result
==
null
||
pipe
==
null
)
return
;
if
(
pid
[
0
]
!=
-
1
)
{
exitcode
=
Exec
.
waitFor
(
pid
[
0
]);
...
...
@@ -125,8 +125,7 @@ public class Utils {
// Read stdout
while
(
stdout
.
available
()
>
0
)
{
read
=
stdout
.
read
(
buf
);
if
(
result
!=
null
)
result
.
append
(
new
String
(
buf
,
0
,
read
));
result
.
append
(
new
String
(
buf
,
0
,
read
));
}
}
catch
(
Exception
ex
)
{
...
...
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