Bug 37695
Summary: | rpm leaves duplicate of STDOUT_FILENO in script processes | ||
---|---|---|---|
Product: | [Retired] Red Hat Linux | Reporter: | Greg Hudson <ghudson> |
Component: | rpm | Assignee: | Jeff Johnson <jbj> |
Status: | CLOSED RAWHIDE | QA Contact: | David Lawrence <dkl> |
Severity: | medium | Docs Contact: | |
Priority: | medium | ||
Version: | 7.1 | ||
Target Milestone: | --- | ||
Target Release: | --- | ||
Hardware: | i386 | ||
OS: | Linux | ||
Whiteboard: | |||
Fixed In Version: | Doc Type: | Bug Fix | |
Doc Text: | Story Points: | --- | |
Clone Of: | Environment: | ||
Last Closed: | 2001-04-26 12:29:37 UTC | Type: | --- |
Regression: | --- | Mount Type: | --- |
Documentation: | --- | CRM: | |
Verified Versions: | Category: | --- | |
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
Cloudforms Team: | --- | Target Upstream Version: | |
Embargoed: |
Description
Greg Hudson
2001-04-25 21:42:19 UTC
The problem is actually worse than stdout, as the same affected daemons will inherit open rpmdb file descriptors as well. So far, I've been saying Fix the daemon package. as daemons truly must lose all open file descriptors, that's SOP in BSD daemonize() for A Long Time Now. Closing and reopening the rpmdb descriptors, unlike stdout, is trickier ... Can't you just set the rpmdb file descriptors FD_CLOEXEC? Unlike stdout, they shouldn't be needed by any subprocess of rpm. Anyway, the overall problem may be larger than stdout, but the stdout problem can have a particularly nasty failure mode, and is easy to fix. Finally, the BSD daemon() function does not close all file descriptors; it merely redirects 0/1/2 to /dev/null. I checked NetBSD, FreeBSD, and OpenBSD; here's a URL to the current NetBSD version for reference. http://cvsweb.netbsd.org/bsdweb.cgi/basesrc/lib/libc/gen/daemon.c?rev=1.8&content-type=text/x-cvsweb-markup Close on exec would work, might have some portability problems. You're correct that stdout is a different, and probably solvable, problem I'll take a look. Thanks for the correction wrto daemonize(), although I'm quite sure that I've seen all file descriptors being routinely closed in BSD code, even though I've mistakenly identified the routine. Let me try a different tack. Any daemon that inherits file descriptors from rpm will inherit file descriptors from whatever program starts the daemon. That indicates that the daemon *must* be fixed, independent of what rpm (or any other program that starts daemons) does. That's the correct way to prevent surprising fd inheiritance. OK, the single open(2) call deep in rpmio now is dressed with FD_CLOEXEC. Will be in rpm-4.0.4-0.30 (and rpm-4.0.4 final). I believe most everything else now sets FD_CLOEXEC, will check. Nothing to be done for stdout/stderr however, they'll inherit from the invoking shell as always. |