Note: This is a beta release of Red Hat Bugzilla 5.0. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Also email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback here.
Bug 163484 - crond doesn't initialise SIGPIPE handler
Summary: crond doesn't initialise SIGPIPE handler
Alias: None
Product: Red Hat Enterprise Linux 3
Classification: Red Hat
Component: vixie-cron
Version: 3.0
Hardware: All
OS: Linux
Target Milestone: ---
Assignee: Marcela Mašláňová
QA Contact: Brock Organ
Depends On:
TreeView+ depends on / blocked
Reported: 2005-07-18 08:32 UTC by Kjetil T. Homme
Modified: 2007-11-30 22:07 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Last Closed: 2006-10-30 09:49:06 UTC
Target Upstream Version:

Attachments (Terms of Use)

Description Kjetil T. Homme 2005-07-18 08:32:20 UTC
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.8) Gecko/20050513

Description of problem:
crond trusts the signal settings for SIGPIPE can be used when spawning its own children.  this is not a safe assumption, it needs to explicitly set it to SIG_DFL before launching child processes.  see bug 146849 and bug 163483.

Version-Release number of selected component (if applicable):

How reproducible:

Steps to Reproduce:
compile this small program:

#include <stdio.h>
#include <signal.h>

int main() {
        sig_t old = signal(SIGPIPE, SIG_DFL);
        if (old == SIG_DFL) puts("SIG_DFL");
        else if (old == SIG_IGN) puts("SIG_IGN");
        else puts("UNKNOWN");
        return 0;

now as root:

trap "" PIPE
/etc/init.d/crond stop
/etc/init.d/crond start

install a crontab running the above program, and direct its output somewhere.

Actual Results:  the log file contains SIG_IGN

Expected Results:  crond should reset the SIGPIPE handler to SIG_DFL.

Additional info:

Comment 1 Jason Vas Dias 2005-07-18 13:59:33 UTC
I've read bug 146849 and bug 163483 as you suggested. 

The root cause of the problem seems to be RPM running its %post scripts
with "trap '' PIPE":
"  in ./rpmdb/rpmdb.c, SIGPIPE is set to be ignored before opening the RPM
   database.  it is not reset until the database has been closed.  in the 
   meantime, some packages will spawn scripts to do pre- or post-install, 
   and these will inherit the SIGPIPE setting.  in our case, this is crond,
   which in turn is passing it on to its children.
Because RPM is running 'service crond restart' after an vixie-cron update
with SIGPIPE set to SIG_IGN, the problems in bug 146849 occur unless 
vixie-cron is restarted normally - correct ?

I don't think vixie-cron should disable all inherited signal handlers by 
default - perhaps someone might want it to inherit a signal handler. 

If vixie-cron should reset SIGPIPE handling to SIG_DFL, it should do so 
for EVERY signal that it does not explicitly set a handler for, and so 
should every process that may be run from an RPM %post .

Yet processes are meant to be able to assume that signal handlers are at
SIG_DFL on start-up .

So I think we should fix RPM not to run %post scripts with 'trap'-ed signals
rather than patching every process that may be run from a %post script to 
restore signal handling to defaults.

Comment 2 Kjetil T. Homme 2005-07-18 14:12:50 UTC
putting the blame on RPM was a bit rash, I can't reproduce it.  rhnsd is a more
likely culprit.

but I think cron has a special position, and most people expect the environment
it gives new processes to be untainted.  e.g., I would definitely call it a bug
if it inherited the $PATH root had when starting the daemon.  by environment I
mean rlimits, signal handlers and of course environment variables.  (I remember
starting inetd with a full environment 10 years ago.  telnetd didn't clear
$LOGNAME, and they were very confused when various applications identified them
as _me_ :-)

I understand your position, but I think by the principle of least surprise, the
behaviour of crond should be constant, regardless of the circumstances of

Comment 3 Jeff Johnson 2005-10-25 23:40:53 UTC
rpm traps sigpipe in order to gracefully close a rpmdb when less is executed early in
    rpm -qa | less

crond needs to be fixed, because its not only rpm that can do "service crond restart"
with signals in non-default settings, any command run by root will show the same
symptoms if signal handlers are changed.

Comment 4 Marcela Mašláňová 2006-10-30 09:49:06 UTC
This problem will be resolved in a future major release of Red Hat Enterprise 
Linux. Red Hat does not currently plan to provide a resolution for this in a 
Red Hat Enterprise Linux update for currently deployed systems.

Note You need to log in before you can comment on or make changes to this bug.