[PATCH vd_agent_linux 6/7] vdagent: Fix restarting agent

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



We need to pass original argument list, however argv is modified by
g_option_context_parse so save a copy of the array to make possible
to restart with the same arguments.

Signed-off-by: Frediano Ziglio <fziglio@xxxxxxxxxx>
---
 src/vdagent/vdagent.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/vdagent/vdagent.c b/src/vdagent/vdagent.c
index eb741bc..0916029 100644
--- a/src/vdagent/vdagent.c
+++ b/src/vdagent/vdagent.c
@@ -418,6 +418,7 @@ int main(int argc, char *argv[])
     GOptionContext *context;
     GError *error = NULL;
     VDAgent *agent;
+    char **orig_argv = g_memdup(argv, sizeof(char*) * (argc+1));
 
     context = g_option_context_new(NULL);
     g_option_context_add_main_entries(context, entries, NULL);
@@ -465,7 +466,7 @@ reconnect:
     if (version_mismatch) {
         syslog(LOG_INFO, "Version mismatch, restarting");
         sleep(1);
-        execvp(argv[0], argv);
+        execvp(orig_argv[0], orig_argv);
     }
 
     agent = vdagent_new();
@@ -483,6 +484,7 @@ reconnect:
     g_free(fx_dir);
     g_free(portdev);
     g_free(vdagentd_socket);
+    g_free(orig_argv);
 
     return 0;
 }
-- 
2.20.1

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux Virtualization]     [Linux Virtualization]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]