From 2ae279bd15ff665440b4b5ace9477c2062c1efc1 Mon Sep 17 00:00:00 2001 From: Samuel Venable Date: Sun, 31 Mar 2024 18:35:17 -0400 Subject: [PATCH] Add more error handling to bp2::ext cwd.ipp. (#354) * Add more error handling to bp2::ext cwd.ipp. * Remove redundant errno checks these functions don't fail... --- include/boost/process/v2/ext/impl/cwd.ipp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/include/boost/process/v2/ext/impl/cwd.ipp b/include/boost/process/v2/ext/impl/cwd.ipp index 8f828751f..f1307e0d8 100644 --- a/include/boost/process/v2/ext/impl/cwd.ipp +++ b/include/boost/process/v2/ext/impl/cwd.ipp @@ -125,7 +125,6 @@ filesystem::path cwd(boost::process::v2::pid_type pid, boost::system::error_code #elif defined(__FreeBSD__) -// FIXME: Add error handling. filesystem::path cwd(boost::process::v2::pid_type pid, boost::system::error_code & ec) { filesystem::path path; @@ -139,9 +138,7 @@ filesystem::path cwd(boost::process::v2::pid_type pid, boost::system::error_code filestat *fst = nullptr; STAILQ_FOREACH(fst, head, next) { if (fst->fs_uflags & PS_FST_UFLAG_CDIR) - { path = filesystem::canonical(fst->fs_path, ec); - } } procstat_freefiles(proc_stat, head); } @@ -160,7 +157,6 @@ filesystem::path cwd(boost::process::v2::pid_type pid, boost::system::error_code #elif defined(__DragonFly__) -// FIXME: Add error handling. filesystem::path cwd(boost::process::v2::pid_type pid, boost::system::error_code & ec) { filesystem::path path; @@ -185,7 +181,8 @@ filesystem::path cwd(boost::process::v2::pid_type pid, boost::system::error_code } else BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec) - pclose(fp); + if (pclose(fp) == -1) + BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec) } else BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec)