mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-06 17:26:01 +02:00
Ensure constants are constant
Contributed by STMicroelectronics Change-Id: I3ceecdba0bcf5715ce0c4f683fd3fdb9b86ad8b3 Signed-off-by: Torbjörn Svensson <torbjorn.svensson@st.com>
This commit is contained in:
parent
69448337e5
commit
e4c46094b1
6 changed files with 73 additions and 39 deletions
|
@ -7,6 +7,18 @@
|
|||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#undef org_eclipse_cdt_utils_spawner_Spawner_SIG_NOOP
|
||||
#define org_eclipse_cdt_utils_spawner_Spawner_SIG_NOOP 0L
|
||||
#undef org_eclipse_cdt_utils_spawner_Spawner_SIG_HUP
|
||||
#define org_eclipse_cdt_utils_spawner_Spawner_SIG_HUP 1L
|
||||
#undef org_eclipse_cdt_utils_spawner_Spawner_SIG_KILL
|
||||
#define org_eclipse_cdt_utils_spawner_Spawner_SIG_KILL 9L
|
||||
#undef org_eclipse_cdt_utils_spawner_Spawner_SIG_TERM
|
||||
#define org_eclipse_cdt_utils_spawner_Spawner_SIG_TERM 15L
|
||||
#undef org_eclipse_cdt_utils_spawner_Spawner_SIG_INT
|
||||
#define org_eclipse_cdt_utils_spawner_Spawner_SIG_INT 2L
|
||||
#undef org_eclipse_cdt_utils_spawner_Spawner_SIG_CTRLC
|
||||
#define org_eclipse_cdt_utils_spawner_Spawner_SIG_CTRLC 1000L
|
||||
/*
|
||||
* Class: org_eclipse_cdt_utils_spawner_Spawner
|
||||
* Method: exec0
|
||||
|
|
|
@ -228,28 +228,28 @@ JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_raise(JNIEnv *
|
|||
int status = -1;
|
||||
|
||||
switch (sig) {
|
||||
case 0: /* NOOP */
|
||||
case org_eclipse_cdt_utils_spawner_Spawner_SIG_NOOP:
|
||||
status = killpg(pid, 0);
|
||||
if (status == -1) {
|
||||
status = kill(pid, 0);
|
||||
}
|
||||
break;
|
||||
|
||||
case 2: /* INTERRUPT */
|
||||
case org_eclipse_cdt_utils_spawner_Spawner_SIG_INT:
|
||||
status = killpg(pid, SIGINT);
|
||||
if (status == -1) {
|
||||
status = kill(pid, SIGINT);
|
||||
}
|
||||
break;
|
||||
|
||||
case 9: /* KILL */
|
||||
case org_eclipse_cdt_utils_spawner_Spawner_SIG_KILL:
|
||||
status = killpg(pid, SIGKILL);
|
||||
if (status == -1) {
|
||||
status = kill(pid, SIGKILL);
|
||||
}
|
||||
break;
|
||||
|
||||
case 15: /* TERM */
|
||||
case org_eclipse_cdt_utils_spawner_Spawner_SIG_TERM:
|
||||
status = killpg(pid, SIGTERM);
|
||||
if (status == -1) {
|
||||
status = kill(pid, SIGTERM);
|
||||
|
@ -257,9 +257,9 @@ JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_raise(JNIEnv *
|
|||
break;
|
||||
|
||||
default:
|
||||
status = killpg(pid, sig); /* WHAT ?? */
|
||||
status = killpg(pid, sig);
|
||||
if (status == -1) {
|
||||
status = kill(pid, sig); /* WHAT ?? */
|
||||
status = kill(pid, sig);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -78,16 +78,6 @@ static void cleanUpProcBlock(pProcInfo_t pCurProcInfo);
|
|||
|
||||
int interruptProcess(int pid);
|
||||
|
||||
// Signal codes
|
||||
typedef enum {
|
||||
SIG_NOOP, //
|
||||
SIG_HUP, //
|
||||
SIG_INT, //
|
||||
SIG_KILL = 9, //
|
||||
SIG_TERM = 15, //
|
||||
CTRLC = 1000 // special, Windows only. Sends CTRL-C in all cases, even when inferior is a Cygwin program
|
||||
} signals;
|
||||
|
||||
extern CRITICAL_SECTION cs;
|
||||
|
||||
extern wchar_t path[MAX_PATH]; // Directory where spawner.dll is located
|
||||
|
@ -619,7 +609,7 @@ extern "C"
|
|||
pProcInfo_t pCurProcInfo = findProcInfo(uid);
|
||||
|
||||
if (!pCurProcInfo) {
|
||||
if (SIG_INT == signal) { // Try another way
|
||||
if (org_eclipse_cdt_utils_spawner_Spawner_SIG_INT == signal) { // Try another way
|
||||
return interruptProcess(uid);
|
||||
}
|
||||
return -1;
|
||||
|
@ -636,15 +626,15 @@ extern "C"
|
|||
}
|
||||
|
||||
switch (signal) {
|
||||
case SIG_NOOP:
|
||||
case org_eclipse_cdt_utils_spawner_Spawner_SIG_NOOP:
|
||||
// Wait 0 msec -just check if the process has been still running
|
||||
ret = ((WAIT_TIMEOUT == WaitForSingleObject(hProc, 0)) ? 0 : -1);
|
||||
break;
|
||||
case SIG_HUP:
|
||||
case org_eclipse_cdt_utils_spawner_Spawner_SIG_HUP:
|
||||
// Temporary do nothing
|
||||
ret = 0;
|
||||
break;
|
||||
case SIG_TERM:
|
||||
case org_eclipse_cdt_utils_spawner_Spawner_SIG_TERM:
|
||||
if (isTraceEnabled(CDT_TRACE_SPAWNER)) {
|
||||
cdtTrace(L"Spawner received TERM signal for process %i\n", pCurProcInfo->pid);
|
||||
}
|
||||
|
@ -655,7 +645,7 @@ extern "C"
|
|||
ret = 0;
|
||||
break;
|
||||
|
||||
case SIG_KILL:
|
||||
case org_eclipse_cdt_utils_spawner_Spawner_SIG_KILL:
|
||||
if (isTraceEnabled(CDT_TRACE_SPAWNER)) {
|
||||
cdtTrace(L"Spawner received KILL signal for process %i\n", pCurProcInfo->pid);
|
||||
}
|
||||
|
@ -665,12 +655,12 @@ extern "C"
|
|||
}
|
||||
ret = 0;
|
||||
break;
|
||||
case SIG_INT:
|
||||
case org_eclipse_cdt_utils_spawner_Spawner_SIG_INT:
|
||||
ResetEvent(pCurProcInfo->eventWait.handle);
|
||||
SetEvent(pCurProcInfo->eventBreak.handle);
|
||||
ret = (WaitForSingleObject(pCurProcInfo->eventWait.handle, 100) == WAIT_OBJECT_0);
|
||||
break;
|
||||
case CTRLC:
|
||||
case org_eclipse_cdt_utils_spawner_Spawner_SIG_CTRLC:
|
||||
ResetEvent(pCurProcInfo->eventWait.handle);
|
||||
SetEvent(pCurProcInfo->eventCtrlc.handle);
|
||||
ret = (WaitForSingleObject(pCurProcInfo->eventWait.handle, 100) == WAIT_OBJECT_0);
|
||||
|
|
|
@ -29,10 +29,31 @@ import org.eclipse.osgi.util.NLS;
|
|||
|
||||
public class Spawner extends Process {
|
||||
|
||||
public int NOOP = 0;
|
||||
public int HUP = 1;
|
||||
public int KILL = 9;
|
||||
public int TERM = 15;
|
||||
@Deprecated(forRemoval = true)
|
||||
public int NOOP = SIG_NOOP;
|
||||
|
||||
@Deprecated(forRemoval = true)
|
||||
public int HUP = SIG_HUP;
|
||||
|
||||
@Deprecated(forRemoval = true)
|
||||
public int KILL = SIG_KILL;
|
||||
|
||||
@Deprecated(forRemoval = true)
|
||||
public int TERM = SIG_TERM;
|
||||
|
||||
@Deprecated(forRemoval = true)
|
||||
public int INT = SIG_INT;
|
||||
|
||||
/**
|
||||
* @since 5.2
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public int CTRLC = SIG_CTRLC;
|
||||
|
||||
private final static int SIG_NOOP = 0;
|
||||
private final static int SIG_HUP = 1;
|
||||
private final static int SIG_KILL = 9;
|
||||
private final static int SIG_TERM = 15;
|
||||
|
||||
/**
|
||||
* On Windows, what this does is far from easy to explain.
|
||||
|
@ -51,17 +72,14 @@ public class Spawner extends Process {
|
|||
* </ul>
|
||||
*
|
||||
* On non-Windows, raising this just raises a POSIX SIGINT
|
||||
*
|
||||
*/
|
||||
public int INT = 2;
|
||||
private final static int SIG_INT = 2;
|
||||
|
||||
/**
|
||||
* A fabricated signal number for use on Windows only. Tells the starter program to send a CTRL-C
|
||||
* regardless of whether the process is a Cygwin one or not.
|
||||
*
|
||||
* @since 5.2
|
||||
*/
|
||||
public int CTRLC = 1000; // arbitrary high number to avoid collision
|
||||
private final static int SIG_CTRLC = 1000; // arbitrary high number to avoid collision
|
||||
|
||||
int pid = 0;
|
||||
int status;
|
||||
|
@ -323,7 +341,7 @@ public class Spawner extends Process {
|
|||
* linux, interrupt it by raising a SIGINT.
|
||||
*/
|
||||
public int interrupt() {
|
||||
return raise(pid, INT);
|
||||
return raise(pid, SIG_INT);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -334,26 +352,26 @@ public class Spawner extends Process {
|
|||
*/
|
||||
public int interruptCTRLC() {
|
||||
if (Platform.getOS().equals(Platform.OS_WIN32)) {
|
||||
return raise(pid, CTRLC);
|
||||
return raise(pid, SIG_CTRLC);
|
||||
} else {
|
||||
return interrupt();
|
||||
}
|
||||
}
|
||||
|
||||
public int hangup() {
|
||||
return raise(pid, HUP);
|
||||
return raise(pid, SIG_HUP);
|
||||
}
|
||||
|
||||
public int kill() {
|
||||
return raise(pid, KILL);
|
||||
return raise(pid, SIG_KILL);
|
||||
}
|
||||
|
||||
public int terminate() {
|
||||
return raise(pid, TERM);
|
||||
return raise(pid, SIG_TERM);
|
||||
}
|
||||
|
||||
public boolean isRunning() {
|
||||
return (raise(pid, NOOP) == 0);
|
||||
return (raise(pid, SIG_NOOP) == 0);
|
||||
}
|
||||
|
||||
private void exec(String[] cmdarray, String[] envp, String dirpath) throws IOException {
|
||||
|
|
Binary file not shown.
|
@ -68,6 +68,7 @@
|
|||
</p>
|
||||
<ol>
|
||||
<li><a href="#GnuMakefileGeneratorAPI">GnuMakefileGenerator is no longer part of API</a></li>
|
||||
<li><a href="#Spawner.signals">The Spawner signal constants are nolonger API</a></li>
|
||||
</ol>
|
||||
|
||||
<p>
|
||||
|
@ -500,7 +501,7 @@
|
|||
|
||||
<h3>1. <a name="GnuMakefileGeneratorAPI">GnuMakefileGenerator is no longer part of API</a></h3>
|
||||
<p>
|
||||
The following classes have been removed from the API.
|
||||
The following classes will be removed from the API.
|
||||
</p>
|
||||
<ul>
|
||||
<li>org.eclipse.cdt.managedbuilder.makegen.gnu.GnuMakefileGenerator</li>
|
||||
|
@ -510,6 +511,19 @@
|
|||
<p>
|
||||
See <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=505882" target="_blank">Bug 505882</a>.
|
||||
</p>
|
||||
|
||||
<h3>2. <a name="Spawner.signals">The Spawner signal constants are nolonger API</a></h3>
|
||||
<p>
|
||||
The following constants will be removed from the Spawner API.
|
||||
</p>
|
||||
<ul>
|
||||
<li>NOOP</li>
|
||||
<li>HUP</li>
|
||||
<li>KILL</li>
|
||||
<li>TERM</li>
|
||||
<li>INT</li>
|
||||
<li>CTRLC</li>
|
||||
</ul>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
|
Loading…
Add table
Reference in a new issue