File indexing completed on 2025-01-18 09:50:05
0001
0002
0003
0004
0005
0006 #ifndef BOOST_PROCESS_DETAIL_POSIX_COMPARE_HANDLES_HPP_
0007 #define BOOST_PROCESS_DETAIL_POSIX_COMPARE_HANDLES_HPP_
0008
0009
0010 #include <boost/process/detail/config.hpp>
0011 #include <sys/types.h>
0012 #include <sys/stat.h>
0013 #include <unistd.h>
0014
0015 namespace boost { namespace process { namespace detail { namespace posix {
0016
0017
0018 inline bool compare_handles(int lhs, int rhs)
0019 {
0020
0021 if ((lhs == -1) || (rhs == -1))
0022 return false;
0023
0024 if (lhs == rhs)
0025 return true;
0026
0027 struct stat stat1, stat2;
0028 if(fstat(lhs, &stat1) < 0) ::boost::process::detail::throw_last_error("fstat() failed");
0029 if(fstat(rhs, &stat2) < 0) ::boost::process::detail::throw_last_error("fstat() failed");
0030
0031 return (stat1.st_dev == stat2.st_dev) && (stat1.st_ino == stat2.st_ino);
0032 }
0033
0034
0035
0036
0037
0038 }}}}
0039
0040
0041
0042 #endif