diff options
| author | Julian Andres Klode <jak@debian.org> | 2025-10-20 20:26:49 +0200 |
|---|---|---|
| committer | Julian Andres Klode <jak@debian.org> | 2025-10-20 20:26:49 +0200 |
| commit | bb1e6834e8a1cd6fd5b88b5a1962e9d813a080fc (patch) | |
| tree | 4d7562b64206a52f6f7918be422b080f239a8d56 /apt-pkg/install-progress.cc | |
| parent | 3dea3434bf2003b757d7ecdb5a8194c8a0c7023f (diff) | |
Correctly append or remove FD_CLOEXEC
Rather than just setting the flags to 0 or FD_CLOEXEC, read
the current value and append or remove as needed.
Diffstat (limited to 'apt-pkg/install-progress.cc')
| -rw-r--r-- | apt-pkg/install-progress.cc | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/apt-pkg/install-progress.cc b/apt-pkg/install-progress.cc index fe3324426..6ff8c3140 100644 --- a/apt-pkg/install-progress.cc +++ b/apt-pkg/install-progress.cc @@ -98,7 +98,8 @@ void PackageManagerProgressFd::StartDpkg() // FIXME: use SetCloseExec here once it taught about throwing // exceptions instead of doing _exit(100) on failure - fcntl(OutStatusFd,F_SETFD,FD_CLOEXEC); + if (auto flags = fcntl(OutStatusFd, F_GETFD); flags >= 0) + fcntl(OutStatusFd, F_SETFD, flags | FD_CLOEXEC); // send status information that we are about to fork dpkg WriteToStatusFd(GetProgressFdString("pmstatus", "dpkg-exec", StepsDone, StepsTotal, _("Running dpkg"))); @@ -180,7 +181,8 @@ void PackageManagerProgressDeb822Fd::StartDpkg() { // FIXME: use SetCloseExec here once it taught about throwing // exceptions instead of doing _exit(100) on failure - fcntl(OutStatusFd,F_SETFD,FD_CLOEXEC); + if (auto flags = fcntl(OutStatusFd, F_GETFD); flags >= 0) + fcntl(OutStatusFd, F_SETFD, flags | FD_CLOEXEC); WriteToStatusFd(GetProgressDeb822String("progress", nullptr, StepsDone, StepsTotal, _("Running dpkg"))); } |
