tools: set cwd when spawning with sysprof-cli

This commit is contained in:
Christian Hergert
2019-07-28 12:31:07 -07:00
parent 745f4c4168
commit 8c72bafff8
6 changed files with 68 additions and 2 deletions

View File

@ -38,6 +38,7 @@ struct _SysprofSpawnable
GArray *fds;
GPtrArray *argv;
gchar **environ;
gchar *cwd;
gint next_fd;
};
@ -270,7 +271,11 @@ sysprof_spawnable_spawn (SysprofSpawnable *self,
launcher = g_subprocess_launcher_new (0);
g_subprocess_launcher_set_environ (launcher, self->environ);
g_subprocess_launcher_set_cwd (launcher, g_get_home_dir ());
if (self->cwd != NULL)
g_subprocess_launcher_set_cwd (launcher, self->cwd);
else
g_subprocess_launcher_set_cwd (launcher, g_get_home_dir ());
for (guint i = 0; i < self->fds->len; i++)
{
@ -284,3 +289,16 @@ sysprof_spawnable_spawn (SysprofSpawnable *self,
return g_subprocess_launcher_spawnv (launcher, argv, error);
}
void
sysprof_spawnable_set_cwd (SysprofSpawnable *self,
const gchar *cwd)
{
g_return_if_fail (SYSPROF_IS_SPAWNABLE (self));
if (g_strcmp0 (cwd, self->cwd) != 0)
{
g_free (self->cwd);
self->cwd = g_strdup (cwd);
}
}