← Back to Pull requests

Use getexecpath() on OpenBSD for get_process_name() #257

Merged
brad0 merged 1 files (35 lines) on Sep 24, 2026 09:05 UTC
View on GitHub
brad0 brad0 commented on Sep 23, 2026 23:07 UTC
Author

No description provided by author.

Diff: 35 lines (+35 / -0) across 1 files Reviewer: Lastique Review duration: 597m
All Vouch review confidence checks passed
Residual risk 0.02 = Change Risk (0.24) × (1 − Review Confidence (0.91)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.24 · 35 lines diff across 1 files
0.24
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.90 · 5 substantive comment(s)
0.90
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 50%
91%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size diff_size
0.214
Real PR Conversation Timeline
8 items
Lastique Lastique commented on code on Sep 23, 2026 23:58 UTC
Code Review
src/process_name.cpp:1
@@ -26,6 +26,10 @@
 #define PATH_MAX 1024
 #endif
 
+#ifdef __OpenBSD__
+#include <sys/param.h>
+#endif
+

This should be moved into the added section for OpenBSD.

Lastique Lastique commented on code on Sep 24, 2026 00:01 UTC
Code Review
src/process_name.cpp:1
@@ -148,6 +152,36 @@ BOOST_LOG_CLOSE_NAMESPACE // namespace log
 
 #include <boost/log/detail/footer.hpp>
 
+#elif defined(__OpenBSD__) && OpenBSD >= 202610
+
+#include <unistd.h>
+#include <boost/log/detail/header.hpp>
+
+namespace boost {
+
+BOOST_LOG_OPEN_NAMESPACE
+
+namespace aux {
+
+//! The function returns the current process name
+BOOST_LOG_API std::string get_process_name()
+{
+    char buf[PATH_MAX];
+
+    if (getexecpath(buf, sizeof(buf)) == 0)

What if PATH_MAX is not large enough? Is there an upper bound for path size on OpenBSD?

brad0 brad0 commented on code on Sep 24, 2026 00:04 UTC
Code Review
src/process_name.cpp:1
@@ -148,6 +152,36 @@ BOOST_LOG_CLOSE_NAMESPACE // namespace log
 
 #include <boost/log/detail/footer.hpp>
 
+#elif defined(__OpenBSD__) && OpenBSD >= 202610
+
+#include <unistd.h>
+#include <boost/log/detail/header.hpp>
+
+namespace boost {
+
+BOOST_LOG_OPEN_NAMESPACE
+
+namespace aux {
+
+//! The function returns the current process name
+BOOST_LOG_API std::string get_process_name()
+{
+    char buf[PATH_MAX];
+
+    if (getexecpath(buf, sizeof(buf)) == 0)

Yes, PATH_MAX. It is internally limited to PATH_MAX - 1 and NUL terminated.

Lastique Lastique commented on code on Sep 24, 2026 00:29 UTC
Code Review
src/process_name.cpp:1
@@ -148,6 +152,36 @@ BOOST_LOG_CLOSE_NAMESPACE // namespace log
 
 #include <boost/log/detail/footer.hpp>
 
+#elif defined(__OpenBSD__) && OpenBSD >= 202610
+
+#include <unistd.h>
+#include <boost/log/detail/header.hpp>
+
+namespace boost {
+
+BOOST_LOG_OPEN_NAMESPACE
+
+namespace aux {
+
+//! The function returns the current process name
+BOOST_LOG_API std::string get_process_name()
+{
+    char buf[PATH_MAX];
+
+    if (getexecpath(buf, sizeof(buf)) == 0)

I asked because getexecpath docs say that the path may exceed PATH_MAX, and there isn't an obvious way to obtain the actual length of the path. So I was wondering if there was a larger actual limit for the path size.

Before this change, the branch below was used, calling read_symlink on one of the proc files. Assuming that one of those files exist on OpenBSD, that code would use readlink with an exponentially increasing buffer size, up to a limit, here. If you want to use getexecpath instead of that code path, I think, a similar logic around getexecpath needs to be implemented here.

brad0 brad0 commented on code on Sep 24, 2026 00:30 UTC
Code Review
src/process_name.cpp:1
@@ -148,6 +152,36 @@ BOOST_LOG_CLOSE_NAMESPACE // namespace log
 
 #include <boost/log/detail/footer.hpp>
 
+#elif defined(__OpenBSD__) && OpenBSD >= 202610
+
+#include <unistd.h>
+#include <boost/log/detail/header.hpp>
+
+namespace boost {
+
+BOOST_LOG_OPEN_NAMESPACE
+
+namespace aux {
+
+//! The function returns the current process name
+BOOST_LOG_API std::string get_process_name()
+{
+    char buf[PATH_MAX];
+
+    if (getexecpath(buf, sizeof(buf)) == 0)

No, OpenBSD does not use the /proc filesystem. Its like the code builds but we've never had a proper API and that's always been an issue.

No, internally it is capped at PATH_MAX in the kernel.

https://github.com/openbsd/src/commit/4dde6567f895c6faa36acbacd4cdf62954a70399

libc function

https://github.com/openbsd/src/commit/026846f111232f45cd1f4883414c190c8ff722a7

Lastique Lastique commented on code on Sep 24, 2026 00:46 UTC
Code Review
src/process_name.cpp:1
@@ -148,6 +152,36 @@ BOOST_LOG_CLOSE_NAMESPACE // namespace log
 
 #include <boost/log/detail/footer.hpp>
 
+#elif defined(__OpenBSD__) && OpenBSD >= 202610
+
+#include <unistd.h>
+#include <boost/log/detail/header.hpp>
+
+namespace boost {
+
+BOOST_LOG_OPEN_NAMESPACE
+
+namespace aux {
+
+//! The function returns the current process name
+BOOST_LOG_API std::string get_process_name()
+{
+    char buf[PATH_MAX];
+
+    if (getexecpath(buf, sizeof(buf)) == 0)

I see, thanks for the information.

Lastique Lastique commented on Sep 24, 2026 09:05 UTC
Contributor

Thank you.

Reviewers
Assignees
brad0 brad0
Labels
risk: low confidence: 91.2% reviewed
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 24.4% (LOW) · Higher = larger blast radius
24.4%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 91.2% · Lower = rushed or shallow review
91.2%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 2.2% · Safe to merge
2.2%
Repository