Skip to content

Commit

Permalink
Add plumbing for getting crashpad_handler's IPC pipe name (#10)
Browse files Browse the repository at this point in the history
This will allow a child process to connect to the pipe server rather than starting its own crashpad_handler.
  • Loading branch information
sgraham authored Apr 29, 2024
1 parent 29f6f8e commit 4b62276
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 0 deletions.
8 changes: 8 additions & 0 deletions include/sentry.h
Original file line number Diff line number Diff line change
Expand Up @@ -1212,6 +1212,14 @@ SENTRY_API void sentry_options_set_database_pathw(
sentry_options_t *opts, const wchar_t *path);
SENTRY_API void sentry_options_set_database_pathw_n(
sentry_options_t *opts, const wchar_t *path, size_t path_len);

/**
* Returns the name of the named pipe where the Crashpad handler is listening
* for child connections if Crashpad is active backend.
*/
SENTRY_API const wchar_t *sentry_options_get_handler_ipc_pipew(
sentry_options_t *opts);

#endif

/**
Expand Down
5 changes: 5 additions & 0 deletions src/backends/sentry_backend_crashpad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,11 @@ crashpad_backend_startup(
annotations, arguments,
/* restartable */ true,
/* asynchronous_start */ false, attachments);
#ifdef SENTRY_PLATFORM_WINDOWS
std::wstring pipe_name = data->client->GetHandlerIPCPipe();
const_cast<sentry_options_t *>(options)->handler_ipc_pipe
= sentry__path_new(pipe_name.c_str());
#endif
sentry_free(minidump_url);
} else {
SENTRY_WARN(
Expand Down
6 changes: 6 additions & 0 deletions src/sentry_options.c
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,12 @@ sentry_options_set_database_pathw(sentry_options_t *opts, const wchar_t *path)
}
#endif

const wchar_t *
sentry_options_get_handler_ipc_pipew(sentry_options_t *opts)
{
return opts->handler_ipc_pipe ? opts->handler_ipc_pipe->path : NULL;
}

/**
* Sets the maximum number of spans that can be attached to a
* transaction.
Expand Down
5 changes: 5 additions & 0 deletions src/sentry_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ typedef struct sentry_options_s {
struct sentry_backend_s *backend;
sentry_session_t *session;

#ifdef SENTRY_PLATFORM_WINDOWS
/* Filled out after crashpad startup, only on Windows */
sentry_path_t* handler_ipc_pipe;
#endif

long user_consent;
long refcount;
uint64_t shutdown_timeout;
Expand Down

0 comments on commit 4b62276

Please sign in to comment.