Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoreutarass2010-01-04 20:13:18 +0000
committereutarass2010-01-04 20:13:18 +0000
commitd09f3b472236d3329ed8648b4ea773ae76f80471 (patch)
treea0dcb293ad616e7d03263935d83b1db3f285ef9d
parente4d12adfd4e4aa10a6c9c83e5d0654c5c5dff60a (diff)
downloadorg.eclipse.tcf.agent-d09f3b472236d3329ed8648b4ea773ae76f80471.tar.gz
org.eclipse.tcf.agent-d09f3b472236d3329ed8648b4ea773ae76f80471.tar.xz
org.eclipse.tcf.agent-d09f3b472236d3329ed8648b4ea773ae76f80471.zip
TCF Agent: fixed: RunControl getState command should return error if the context does not have a state
-rw-r--r--services/runctrl.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/services/runctrl.c b/services/runctrl.c
index dff6a23d..8156fc66 100644
--- a/services/runctrl.c
+++ b/services/runctrl.c
@@ -346,19 +346,22 @@ static void command_get_children(char * token, Channel * c) {
static void command_get_state(char * token, Channel * c) {
char id[256];
- Context * ctx;
+ pid_t pid, ppd;
+ Context * ctx = NULL;
int err = 0;
json_read_string(&c->inp, id, sizeof(id));
if (read_stream(&c->inp) != 0) exception(ERR_JSON_SYNTAX);
if (read_stream(&c->inp) != MARKER_EOM) exception(ERR_JSON_SYNTAX);
- ctx = id2ctx(id);
+
+ pid = id2pid(id, &ppd);
+ if (pid != 0 && ppd != 0) ctx = context_find_from_pid(pid);
+ if (ctx == NULL || !context_has_state(ctx)) err = ERR_INV_CONTEXT;
+ else if (ctx->exited) err = ERR_ALREADY_EXITED;
write_stringz(&c->out, "R");
write_stringz(&c->out, token);
- if (ctx == NULL) err = ERR_INV_CONTEXT;
- else if (ctx->exited) err = ERR_ALREADY_EXITED;
write_errno(&c->out, err);
json_write_boolean(&c->out, ctx != NULL && ctx->intercepted);

Back to the top