Python, in order to be able to throw an OSError(EPIPE) exception rather
than terminating directly upon writing to a closed pipe, sets the signal
disposition for SIGPIPE to SIG_IGN. Unfortunately, POSIX specifies under
exec*() that "Except for SIGCHLD, signals set to be ignored (SIG_IGN) by
the calling process image shall be set to be ignored by the new process
image.". This means that, unless some program itself takes an explicit
step to restore the default disposition for SIGPIPE, the entire
subprocess tree will receive -EPIPE upon writing to a closed pipe rather
than being terminated automatically. If some program down the tree,
knowingly or not, relies on the usual behaviour, this can lead to
hard-to-debug errors (or worse, http://bugs.python.org/issue1652).
This is fixed in Python 3.2+, at least for the subprocess module, but we
have to do it ourselves. This just changes the two most important users,
oelite.util.shcmd() and oelite.function.ShellFunction (the latter being
the one that handles all task, pre- and postfunctions which are
implemented as bash scripts, which is where the deepest subprocess trees
are created).
Python, in order to be able to throw an OSError(EPIPE) exception rather than terminating directly upon writing to a closed pipe, sets the signal disposition for SIGPIPE to SIG_IGN. Unfortunately, POSIX specifies under exec*() that "Except for SIGCHLD, signals set to be ignored (SIG_IGN) by the calling process image shall be set to be ignored by the new process image.". This means that, unless some program itself takes an explicit step to restore the default disposition for SIGPIPE, the entire subprocess tree will receive -EPIPE upon writing to a closed pipe rather than being terminated automatically. If some program down the tree, knowingly or not, relies on the usual behaviour, this can lead to hard-to-debug errors (or worse, http://bugs.python.org/issue1652).
This is fixed in Python 3.2+, at least for the subprocess module, but we have to do it ourselves. This just changes the two most important users, oelite.util.shcmd() and oelite.function.ShellFunction (the latter being the one that handles all task, pre- and postfunctions which are implemented as bash scripts, which is where the deepest subprocess trees are created).