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

Frediano Ziglio fziglio at redhat.com
Thu Jan 3 10:02:46 UTC 2019


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 at redhat.com>
---
 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



More information about the Spice-devel mailing list