1
0
mirror of http://galexander.org/git/simplesshd.git synced 2024-11-14 02:59:05 +00:00

make sshd_pid static

This commit is contained in:
Greg Alexander 2014-12-16 11:19:26 -05:00
parent e1d43c3208
commit 9cac7ed132
2 changed files with 6 additions and 6 deletions

View File

@ -31,7 +31,7 @@ jni_init(JNIEnv *env_)
CLASS(string, "java/lang/String")
CLASS(simplesshdservice, "org/galexander/sshd/SimpleSSHDService")
FIELD(sss_sshd_pid, simplesshdservice, "sshd_pid", "I")
STFIELD(sss_sshd_pid, simplesshdservice, "sshd_pid", "I")
return 1;
}
@ -48,7 +48,7 @@ Java_org_galexander_sshd_SimpleSSHDService_start_1sshd(JNIEnv *env_,
if (pid == 0) {
/* XXX - call dropbear main() */
} 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_)) {
return;
}
pid = (*env)->GetIntField(env, this, fid_sss_sshd_pid);
pid = (*env)->GetStaticIntField(env, cl_simplesshdservice, fid_sss_sshd_pid);
kill(pid, SIGKILL);
(*env)->SetIntField(env, this, fid_sss_sshd_pid, 0);
(*env)->SetStaticIntField(env, cl_simplesshdservice, fid_sss_sshd_pid, 0);
}

View File

@ -5,7 +5,7 @@ import android.content.Intent;
import android.os.IBinder;
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) {
if ((intent == null) ||
@ -24,7 +24,7 @@ public class SimpleSSHDService extends Service {
return null;
}
public boolean is_started() {
public static boolean is_started() {
return (sshd_pid != 0);
}