mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2026-02-09 22:50:54 +00:00
libsysprof: notify instruments of process spawn
This commit is contained in:
@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
#include <sys/sysinfo.h>
|
#include <sys/sysinfo.h>
|
||||||
#include <sys/utsname.h>
|
#include <sys/utsname.h>
|
||||||
|
|
||||||
@ -93,17 +94,27 @@ G_DEFINE_FINAL_TYPE (SysprofRecording, sysprof_recording, G_TYPE_OBJECT)
|
|||||||
static GParamSpec *properties[N_PROPS];
|
static GParamSpec *properties[N_PROPS];
|
||||||
|
|
||||||
static DexFuture *
|
static DexFuture *
|
||||||
_sysprof_recording_spawn (SysprofSpawnable *spawnable,
|
_sysprof_recording_spawn (SysprofRecording *self,
|
||||||
|
SysprofSpawnable *spawnable,
|
||||||
GSubprocess **subprocess)
|
GSubprocess **subprocess)
|
||||||
{
|
{
|
||||||
g_autoptr(GError) error = NULL;
|
g_autoptr(GError) error = NULL;
|
||||||
|
const char *identifier;
|
||||||
DexFuture *ret;
|
DexFuture *ret;
|
||||||
|
|
||||||
g_assert (SYSPROF_IS_SPAWNABLE (spawnable));
|
g_assert (SYSPROF_IS_SPAWNABLE (spawnable));
|
||||||
|
g_assert (subprocess != NULL);
|
||||||
|
g_assert (*subprocess == NULL);
|
||||||
|
|
||||||
if (!(*subprocess = sysprof_spawnable_spawn (spawnable, &error)))
|
if (!(*subprocess = sysprof_spawnable_spawn (spawnable, &error)))
|
||||||
return dex_future_new_for_error (g_steal_pointer (&error));
|
return dex_future_new_for_error (g_steal_pointer (&error));
|
||||||
|
|
||||||
|
if ((identifier = g_subprocess_get_identifier (*subprocess)))
|
||||||
|
{
|
||||||
|
int pid = atoi (identifier);
|
||||||
|
dex_await (_sysprof_instruments_process_started (self->instruments, self, pid), NULL);
|
||||||
|
}
|
||||||
|
|
||||||
ret = dex_subprocess_wait_check (*subprocess);
|
ret = dex_subprocess_wait_check (*subprocess);
|
||||||
dex_async_pair_set_cancel_on_discard (DEX_ASYNC_PAIR (ret), FALSE);
|
dex_async_pair_set_cancel_on_discard (DEX_ASYNC_PAIR (ret), FALSE);
|
||||||
return ret;
|
return ret;
|
||||||
@ -186,7 +197,7 @@ sysprof_recording_fiber (gpointer user_data)
|
|||||||
|
|
||||||
/* If we need to spawn a subprocess, do it now */
|
/* If we need to spawn a subprocess, do it now */
|
||||||
if (self->spawnable != NULL)
|
if (self->spawnable != NULL)
|
||||||
monitor = _sysprof_recording_spawn (self->spawnable, &self->subprocess);
|
monitor = _sysprof_recording_spawn (self, self->spawnable, &self->subprocess);
|
||||||
else
|
else
|
||||||
monitor = dex_future_new_infinite ();
|
monitor = dex_future_new_infinite ();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user