Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Bash reports error "-bash: child setpgid (12743 to 12739): Operation not permitted" when pipe is used in commands.
- SOLUTION VERIFIED - Updated August 27 2013 at 7:22 AM - English
- Environment
- Red Hat Enterprise Linux (RHEL) 5
- bash-3.2-32.el5
- Issue
- When pipe character is used in between the commands, bash reports the errors/warnings like follows.
- Raw
- [root@localhost ~]# ls | less
- -bash: child setpgid (12743 to 12739): Operation not permitted
- -bash: child setpgid (12745 to 12739): Operation not permitted
- -bash: child setpgid (12746 to 12739): Operation not permitted
- anaconda-ks.cfg
- install.log
- install.log.syslog
- Why its happening?
- Is there any way to get it cleared?
- Resolution
- Remove definition of DEBUG trap from logging scripts.
- Root Cause
- There was a logging function:
- Raw
- log ()
- {
- typeset -r WHOIAM=$(who -m);
- typeset -r WHOAMI=$(whoami);
- typeset -r x=$(history 1 |tail -1 );
- [[ $SECONDS -gt 2 ]] && /bin/logger -p local4.debug -t $WHOIAM $WHOAMI $PWD "${x# }"
- }
- and DEBUG trap:
- Raw
- trap 'log' DEBUG
- defined in customer's logging scripts.
- A known bug causes intermittent errors when a command with pipeline is issued while the DEBUG trap is enabled. The bug was fixed in bash-4.1. The fix cannot be backported to RHEL 5 because of Production 2 Phase Bug Fix inclusion restrictions.
- Diagnostic Steps
- capture strace:
- Raw
- # ps
- PID TTY TIME CMD
- 1047 pts/2 00:00:00 bash
- 1372 pts/2 00:00:00 ps
- # strace -ttfFv -p 1047 -o /tmp/strace.pipe &
- # ls | less
- # fg
- strace -ttfFv -p 1047 -o /tmp/strace.pipe
- Process 1047 detached
- ^C
- explore strace.pipe
- from grep -E 'execve|clone|exit_group|setpgid' strace.pipe we could see
- setpgid() is trying to set process group ID to already exited process - race condition bug?
- there are more unexpected processes executed (who, whoami, tail, logger) before spawning ls and the same before spawning less - could be a DEBUG trap?
- search bugzilla
- Raw
- Summary: debug trap
- Classification: Red Hat
- Component: bash
- Product: Red Hat Enterprise Linux 2.1, Red Hat Enterprise Linux 3,
- Red Hat Enterprise Linux 4, Red Hat Enterprise Linux 5,
- Red Hat Enterprise Linux 6, Red Hat Enterprise Linux 7
- gives https://bugzilla.redhat.com/show_bug.cgi?id=720464
- * check the traps:
- Raw
- # trap -p
- trap -- 'log' DEBUG
- check the 'log' command:
- Raw
- # type log
- log is a function
- log ()
- {
- typeset -r WHOIAM=$(who -m);
- typeset -r WHOAMI=$(whoami);
- typeset -r x=$(history 1 |tail -1 );
- [[ $SECONDS -gt 2 ]] && /bin/logger -p local4.debug -t $WHOIAM $WHOAMI $PWD "${x# }"
- }
- explore logging scripts where 'log' is defined
- Raw
- # set -x
- # . /etc/profile &>/tmp/etc_profile.xtrace
- # . ~/.bash_profile &>/tmp/bash_profile.xtrace
- # . ~/.bash_login &>/tmp/bash_login.xtrace
- # . ~/.profile &>/tmp/dot_profile.xtrace
- # . ~/.bashrc &>/tmp/dot_bashrc.xtrace
- it was also needed to check manually some scripts, that were included with stderr redirection e.g. via line in /etc/profile:
- Raw
- . /etc/custom_profile 2>/dev/null
- so the xtrace of their execution was lost
- Product(s) Red Hat Enterprise Linux Component bash Category Troubleshoot Tags shells
- This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement