mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2026-02-12 16:10:54 +00:00
libsysprof: add accessors for setting spawnable flags
We need this to be able to allow inheriting stdin from sysprof-cli.
This commit is contained in:
@ -34,12 +34,13 @@ typedef struct
|
|||||||
|
|
||||||
struct _SysprofSpawnable
|
struct _SysprofSpawnable
|
||||||
{
|
{
|
||||||
GObject parent_instance;
|
GObject parent_instance;
|
||||||
GArray *fds;
|
GArray *fds;
|
||||||
GPtrArray *argv;
|
GPtrArray *argv;
|
||||||
gchar **environ;
|
char **environ;
|
||||||
gchar *cwd;
|
char *cwd;
|
||||||
gint next_fd;
|
gint next_fd;
|
||||||
|
GSubprocessFlags flags;
|
||||||
};
|
};
|
||||||
|
|
||||||
G_DEFINE_TYPE (SysprofSpawnable, sysprof_spawnable, G_TYPE_OBJECT)
|
G_DEFINE_TYPE (SysprofSpawnable, sysprof_spawnable, G_TYPE_OBJECT)
|
||||||
@ -57,6 +58,41 @@ sysprof_spawnable_new (void)
|
|||||||
return g_object_new (SYSPROF_TYPE_SPAWNABLE, NULL);
|
return g_object_new (SYSPROF_TYPE_SPAWNABLE, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* sysprof_spawnable_get_flags:
|
||||||
|
* @self: a #SysprofSpawnable
|
||||||
|
*
|
||||||
|
* Gets the subprocess flags for spawning.
|
||||||
|
*
|
||||||
|
* Returns: the #GSubprocessFlags bitwise-or'd
|
||||||
|
*
|
||||||
|
* Since: 3.46
|
||||||
|
*/
|
||||||
|
GSubprocessFlags
|
||||||
|
sysprof_spawnable_get_flags (SysprofSpawnable *self)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (SYSPROF_IS_SPAWNABLE (self), 0);
|
||||||
|
|
||||||
|
return self->flags;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* sysprof_spawnable_set_flags:
|
||||||
|
* @self: a #SysprofSpawnable
|
||||||
|
*
|
||||||
|
* Set the flags to use when spawning the process.
|
||||||
|
*
|
||||||
|
* Since: 3.46
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
sysprof_spawnable_set_flags (SysprofSpawnable *self,
|
||||||
|
GSubprocessFlags flags)
|
||||||
|
{
|
||||||
|
g_return_if_fail (SYSPROF_IS_SPAWNABLE (self));
|
||||||
|
|
||||||
|
self->flags = flags;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
fd_mapping_clear (gpointer data)
|
fd_mapping_clear (gpointer data)
|
||||||
{
|
{
|
||||||
@ -268,7 +304,7 @@ sysprof_spawnable_spawn (SysprofSpawnable *self,
|
|||||||
|
|
||||||
g_return_val_if_fail (SYSPROF_IS_SPAWNABLE (self), NULL);
|
g_return_val_if_fail (SYSPROF_IS_SPAWNABLE (self), NULL);
|
||||||
|
|
||||||
launcher = g_subprocess_launcher_new (0);
|
launcher = g_subprocess_launcher_new (self->flags);
|
||||||
|
|
||||||
g_subprocess_launcher_set_environ (launcher, self->environ);
|
g_subprocess_launcher_set_environ (launcher, self->environ);
|
||||||
|
|
||||||
|
|||||||
@ -77,5 +77,10 @@ void sysprof_spawnable_set_starting_fd (SysprofSpawnable
|
|||||||
SYSPROF_AVAILABLE_IN_ALL
|
SYSPROF_AVAILABLE_IN_ALL
|
||||||
GSubprocess *sysprof_spawnable_spawn (SysprofSpawnable *self,
|
GSubprocess *sysprof_spawnable_spawn (SysprofSpawnable *self,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
SYSPROF_AVAILABLE_IN_3_46
|
||||||
|
GSubprocessFlags sysprof_spawnable_get_flags (SysprofSpawnable *self);
|
||||||
|
SYSPROF_AVAILABLE_IN_3_46
|
||||||
|
void sysprof_spawnable_set_flags (SysprofSpawnable *self,
|
||||||
|
GSubprocessFlags flags);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|||||||
Reference in New Issue
Block a user