Skip to content

Commit

Permalink
Add more error handling to bp2::ext cwd.ipp.
Browse files Browse the repository at this point in the history
  • Loading branch information
time-killer-games authored Feb 6, 2024
1 parent 029ad73 commit 2afc1b7
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions include/boost/process/v2/ext/impl/cwd.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -139,19 +138,23 @@ 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);
if (errno)
BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec)
}
else
BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec)
procstat_freeprocs(proc_stat, proc_info);
if (errno)
BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec)
}
else
BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec)
procstat_close(proc_stat);
if (errno)
BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec)
}
else
BOOST_PROCESS_V2_ASSIGN_LAST_ERROR(ec)
Expand All @@ -160,7 +163,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;
Expand All @@ -185,7 +187,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)
Expand Down

0 comments on commit 2afc1b7

Please sign in to comment.