libsysprof-capture: add API to duplicate underlying write FD

This is useful for use in our other libraries that may need access to these
to create document loaders for a completed writer.
This commit is contained in:
Christian Hergert
2023-07-08 11:19:02 -07:00
parent 008b9f4cc1
commit db88129c81
2 changed files with 13 additions and 0 deletions

View File

@ -1704,3 +1704,14 @@ _sysprof_capture_writer_add_raw (SysprofCaptureWriter *self,
return true;
}
int
_sysprof_capture_writer_dup_fd (SysprofCaptureWriter *self)
{
assert (self != NULL);
if (self->fd == -1)
return -1;
return dup (self->fd);
}

View File

@ -244,5 +244,7 @@ SYSPROF_INTERNAL
bool _sysprof_capture_writer_set_time_range (SysprofCaptureWriter *self,
int64_t start_time,
int64_t end_time) SYSPROF_INTERNAL;
SYSPROF_INTERNAL
int _sysprof_capture_writer_dup_fd (SysprofCaptureWriter *self);
SYSPROF_END_DECLS