Integrate conmon into ocid
Signed-off-by: Mrunal Patel <mrunalp@gmail.com>
This commit is contained in:
parent
6e05f772ed
commit
02236bbda0
2 changed files with 75 additions and 1 deletions
|
@ -76,6 +76,9 @@ int main(int argc, char *argv[])
|
|||
struct termios t;
|
||||
struct epoll_event ev;
|
||||
struct epoll_event evlist[MAX_EVENTS];
|
||||
int child_pipe = -1;
|
||||
char *sync_pipe, *endptr;
|
||||
int len;
|
||||
|
||||
while ((opt = getopt(argc, argv, "tc:")) != -1) {
|
||||
switch(opt) {
|
||||
|
@ -101,6 +104,14 @@ int main(int argc, char *argv[])
|
|||
nexit("Container ID not passed");
|
||||
}
|
||||
|
||||
sync_pipe = getenv("_OCI_SYNCPIPE");
|
||||
if (sync_pipe) {
|
||||
errno = 0;
|
||||
child_pipe = strtol(sync_pipe, &endptr, 10);
|
||||
if (errno != 0 || *endptr != '\0')
|
||||
pexit("unable to parse _OCI_SYNCPIPE");
|
||||
}
|
||||
|
||||
/*
|
||||
* Set self as subreaper so we can wait for container process
|
||||
* and return its exit code.
|
||||
|
@ -155,6 +166,14 @@ int main(int argc, char *argv[])
|
|||
cpid = atoi(contents);
|
||||
printf("container PID: %d\n", cpid);
|
||||
|
||||
/* Send the container pid back to parent */
|
||||
if (child_pipe > 0) {
|
||||
len = snprintf(buf, BUF_SIZE, "{\"pid\": %d}\n", cpid);
|
||||
if (len < 0 || write(child_pipe, buf, len) != len) {
|
||||
pexit("unable to send container pid to parent");
|
||||
}
|
||||
}
|
||||
|
||||
if (terminal) {
|
||||
/* Save exiting termios settings */
|
||||
if (tcgetattr(STDIN_FILENO, &tty_orig) == -1)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue