mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEADEV-18231
This commit is contained in:
Binary file not shown.
@@ -0,0 +1,59 @@
|
||||
|
||||
#if defined(WIN32)
|
||||
#include <windows.h>
|
||||
#else
|
||||
#include <jni.h>
|
||||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
int isKernel26OrHigher();
|
||||
#endif
|
||||
|
||||
JNIEXPORT void JNICALL Java_com_intellij_rt_execution_application_AppMain_triggerControlBreak
|
||||
(JNIEnv *env, jclass clazz) {
|
||||
#if defined(WIN32)
|
||||
GenerateConsoleCtrlEvent(CTRL_BREAK_EVENT, 0);
|
||||
#else
|
||||
if (isKernel26OrHigher()) {
|
||||
kill (getpid(), SIGQUIT);
|
||||
} else {
|
||||
int ppid = getppid();
|
||||
char buffer[1024];
|
||||
sprintf(buffer, "/proc/%d/status", ppid);
|
||||
FILE * fp;
|
||||
if ( (fp = fopen(buffer, "r")) != NULL )
|
||||
{
|
||||
char s[124];
|
||||
char * ppid_name = "PPid:";
|
||||
while (fscanf (fp, "%s\n", s) > 0) {
|
||||
if (strcmp(s, ppid_name) == 0) {
|
||||
int pppid;
|
||||
fscanf(fp, "%d", &pppid);
|
||||
kill (pppid, SIGQUIT);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
fclose (fp);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
int isKernel26OrHigher() {
|
||||
char buffer[1024];
|
||||
FILE * fp;
|
||||
if ( (fp = fopen("/proc/version", "r")) != NULL )
|
||||
{
|
||||
int major;
|
||||
int minor;
|
||||
fscanf(fp, "Linux version %d.%d", &major, &minor);
|
||||
return major >=2 && minor >= 6;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user