Skip to content
This repository was archived by the owner on Feb 8, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/api.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ enum {
SETUPROUTE,
REMOVECONTAINER,
PROCESSASYNCEVENT,
SIGNALPROCESS,
};

/*
Expand Down
28 changes: 28 additions & 0 deletions src/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,31 @@ static int hyper_kill_container(struct hyper_pod *pod, char *json, int length)
return ret;
}

static int hyper_signal_process(struct hyper_pod *pod, char *json, int length)
{
struct hyper_exec *exec;
int ret = -1;

JSON_Value *value = hyper_json_parse(json, length);
if (value == NULL) {
goto out;
}

const char *container = json_object_get_string(json_object(value), "container");
const char *process = json_object_get_string(json_object(value), "process");
exec = hyper_find_process(pod, container, process);
if (exec == NULL) {
fprintf(stderr, "can not find process");
goto out;
}

kill(exec->pid, (int)json_object_get_number(json_object(value), "signal"));
ret = 0;
out:
json_value_free(value);
return ret;
}

static int hyper_remove_container(struct hyper_pod *pod, char *json, int length)
{
struct hyper_container *c;
Expand Down Expand Up @@ -1136,6 +1161,9 @@ static int hyper_ctlmsg_handle(struct hyper_event *he, uint32_t len)
case SETUPROUTE:
ret = hyper_cmd_setup_route((char *)buf->data + 8, len - 8);
break;
case SIGNALPROCESS:
ret = hyper_signal_process(pod, (char *)buf->data + 8, len - 8);
break;
case GETPOD_DEPRECATED:
case STOPPOD_DEPRECATED:
case RESTARTCONTAINER_DEPRECATED:
Expand Down