mirror of
http://galexander.org/git/simplesshd.git
synced 2025-01-05 20:50:59 +00:00
make sshd_pid static
This commit is contained in:
parent
e1d43c3208
commit
9cac7ed132
@ -31,7 +31,7 @@ jni_init(JNIEnv *env_)
|
|||||||
CLASS(string, "java/lang/String")
|
CLASS(string, "java/lang/String")
|
||||||
CLASS(simplesshdservice, "org/galexander/sshd/SimpleSSHDService")
|
CLASS(simplesshdservice, "org/galexander/sshd/SimpleSSHDService")
|
||||||
|
|
||||||
FIELD(sss_sshd_pid, simplesshdservice, "sshd_pid", "I")
|
STFIELD(sss_sshd_pid, simplesshdservice, "sshd_pid", "I")
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -48,7 +48,7 @@ Java_org_galexander_sshd_SimpleSSHDService_start_1sshd(JNIEnv *env_,
|
|||||||
if (pid == 0) {
|
if (pid == 0) {
|
||||||
/* XXX - call dropbear main() */
|
/* XXX - call dropbear main() */
|
||||||
} else {
|
} else {
|
||||||
(*env)->SetIntField(env, this, fid_sss_sshd_pid, pid);
|
(*env)->SetStaticIntField(env, cl_simplesshdservice, fid_sss_sshd_pid, pid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,7 +59,7 @@ Java_org_galexander_sshd_SimpleSSHDService_stop_1sshd(JNIEnv *env_, jobject this
|
|||||||
if (!jni_init(env_)) {
|
if (!jni_init(env_)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
pid = (*env)->GetIntField(env, this, fid_sss_sshd_pid);
|
pid = (*env)->GetStaticIntField(env, cl_simplesshdservice, fid_sss_sshd_pid);
|
||||||
kill(pid, SIGKILL);
|
kill(pid, SIGKILL);
|
||||||
(*env)->SetIntField(env, this, fid_sss_sshd_pid, 0);
|
(*env)->SetStaticIntField(env, cl_simplesshdservice, fid_sss_sshd_pid, 0);
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@ import android.content.Intent;
|
|||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
|
|
||||||
public class SimpleSSHDService extends Service {
|
public class SimpleSSHDService extends Service {
|
||||||
public int sshd_pid = 0;
|
public static int sshd_pid = 0;
|
||||||
|
|
||||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||||
if ((intent == null) ||
|
if ((intent == null) ||
|
||||||
@ -24,7 +24,7 @@ public class SimpleSSHDService extends Service {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean is_started() {
|
public static boolean is_started() {
|
||||||
return (sshd_pid != 0);
|
return (sshd_pid != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user