]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
get_init_pid moved to lxc/commands.c
authorMichel Normand <normand@fr.ibm.com>
Thu, 29 Apr 2010 08:03:59 +0000 (10:03 +0200)
committerDaniel Lezcano <dlezcano@fr.ibm.com>
Thu, 29 Apr 2010 08:03:59 +0000 (10:03 +0200)
as will be used later on in other patches.

Signed-off-by: Michel Normand <normand@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
src/lxc/commands.c
src/lxc/commands.h
src/lxc/lxc_attach.c

index 7c24c8170ec782f833cd410a0d63937b5b682b7d..ab230269453d30f0666dca2a479674fa5c001be7 100644 (file)
@@ -111,6 +111,34 @@ out_close:
        goto out;
 }
 
+pid_t get_init_pid(const char *name)
+{
+       struct lxc_command command = {
+               .request = { .type = LXC_COMMAND_PID },
+       };
+
+       int ret, stopped = 0;
+
+       ret = lxc_command(name, &command, &stopped);
+       if (ret < 0 && stopped) {
+               ERROR("'%s' is not running", name);
+               return -1;
+       }
+
+       if (ret < 0) {
+               ERROR("failed to send command");
+               return -1;
+       }
+
+       if (command.answer.ret) {
+               ERROR("failed to retrieve the init pid: %s",
+                     strerror(-command.answer.ret));
+               return -1;
+       }
+
+       return command.answer.pid;
+}
+
 extern void lxc_console_remove_fd(int, struct lxc_tty_info *);
 extern int  lxc_console_callback(int, struct lxc_request *, struct lxc_handler *);
 extern int  lxc_stop_callback(int, struct lxc_request *, struct lxc_handler *);
index e191b779e92bf18a02251c23c5949ff3e04eac7c..b013b7d46b648ba01d248581aca992b1fbab347f 100644 (file)
@@ -47,6 +47,7 @@ struct lxc_command {
        struct lxc_answer answer;
 };
 
+extern pid_t get_init_pid(const char *name);
 extern int lxc_command(const char *name, struct lxc_command *command,
                        int *stopped);
 
index 13b89ff51027d09043fc4b6e14a4e3e8d1e2a11e..3a183a10620f98873be9a6795e84bda7e89b2ab2 100644 (file)
@@ -55,34 +55,6 @@ Options :\n\
        .checker  = NULL,
 };
 
-pid_t get_init_pid(const char *name)
-{
-       struct lxc_command command = {
-               .request = { .type = LXC_COMMAND_PID },
-       };
-
-       int ret, stopped = 0;
-
-       ret = lxc_command(name, &command, &stopped);
-       if (ret < 0 && stopped) {
-               ERROR("'%s' is not running", name);
-               return -1;
-       }
-
-       if (ret < 0) {
-               ERROR("failed to send command");
-               return -1;
-       }
-
-       if (command.answer.ret) {
-               ERROR("failed to retrieve the init pid: %s",
-                     strerror(-command.answer.ret));
-               return -1;
-       }
-
-       return command.answer.pid;
-}
-
 int main(int argc, char *argv[], char *envp[])
 {
        int ret;