Advertisement
Guest User

Untitled

a guest
Jun 8th, 2016
434
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.45 KB | None | 0 0
  1. Bash reports error "-bash: child setpgid (12743 to 12739): Operation not permitted" when pipe is used in commands.
  2. SOLUTION VERIFIED - Updated August 27 2013 at 7:22 AM - English
  3. Environment
  4.  
  5. Red Hat Enterprise Linux (RHEL) 5
  6. bash-3.2-32.el5
  7. Issue
  8.  
  9. When pipe character is used in between the commands, bash reports the errors/warnings like follows.
  10. Raw
  11. [root@localhost ~]# ls | less
  12. -bash: child setpgid (12743 to 12739): Operation not permitted
  13. -bash: child setpgid (12745 to 12739): Operation not permitted
  14. -bash: child setpgid (12746 to 12739): Operation not permitted
  15. anaconda-ks.cfg
  16. install.log
  17. install.log.syslog
  18. Why its happening?
  19. Is there any way to get it cleared?
  20. Resolution
  21.  
  22. Remove definition of DEBUG trap from logging scripts.
  23.  
  24. Root Cause
  25.  
  26. There was a logging function:
  27.  
  28. Raw
  29. log ()
  30. {
  31. typeset -r WHOIAM=$(who -m);
  32. typeset -r WHOAMI=$(whoami);
  33. typeset -r x=$(history 1 |tail -1 );
  34. [[ $SECONDS -gt 2 ]] && /bin/logger -p local4.debug -t $WHOIAM $WHOAMI $PWD "${x# }"
  35. }
  36. and DEBUG trap:
  37.  
  38. Raw
  39. trap 'log' DEBUG
  40. defined in customer's logging scripts.
  41.  
  42. 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.
  43.  
  44. Diagnostic Steps
  45.  
  46. capture strace:
  47. Raw
  48. # ps
  49. PID TTY TIME CMD
  50. 1047 pts/2 00:00:00 bash
  51. 1372 pts/2 00:00:00 ps
  52. # strace -ttfFv -p 1047 -o /tmp/strace.pipe &
  53. # ls | less
  54. # fg
  55. strace -ttfFv -p 1047 -o /tmp/strace.pipe
  56. Process 1047 detached
  57. ^C
  58. explore strace.pipe
  59. from grep -E 'execve|clone|exit_group|setpgid' strace.pipe we could see
  60.  
  61. setpgid() is trying to set process group ID to already exited process - race condition bug?
  62. there are more unexpected processes executed (who, whoami, tail, logger) before spawning ls and the same before spawning less - could be a DEBUG trap?
  63. search bugzilla
  64. Raw
  65. Summary: debug trap
  66. Classification: Red Hat
  67. Component: bash
  68. Product: Red Hat Enterprise Linux 2.1, Red Hat Enterprise Linux 3,
  69. Red Hat Enterprise Linux 4, Red Hat Enterprise Linux 5,
  70. Red Hat Enterprise Linux 6, Red Hat Enterprise Linux 7
  71. gives https://bugzilla.redhat.com/show_bug.cgi?id=720464
  72. * check the traps:
  73.  
  74. Raw
  75. # trap -p
  76. trap -- 'log' DEBUG
  77. check the 'log' command:
  78. Raw
  79. # type log
  80. log is a function
  81. log ()
  82. {
  83. typeset -r WHOIAM=$(who -m);
  84. typeset -r WHOAMI=$(whoami);
  85. typeset -r x=$(history 1 |tail -1 );
  86. [[ $SECONDS -gt 2 ]] && /bin/logger -p local4.debug -t $WHOIAM $WHOAMI $PWD "${x# }"
  87. }
  88. explore logging scripts where 'log' is defined
  89. Raw
  90. # set -x
  91. # . /etc/profile &>/tmp/etc_profile.xtrace
  92. # . ~/.bash_profile &>/tmp/bash_profile.xtrace
  93. # . ~/.bash_login &>/tmp/bash_login.xtrace
  94. # . ~/.profile &>/tmp/dot_profile.xtrace
  95. # . ~/.bashrc &>/tmp/dot_bashrc.xtrace
  96. it was also needed to check manually some scripts, that were included with stderr redirection e.g. via line in /etc/profile:
  97. Raw
  98. . /etc/custom_profile 2>/dev/null
  99. so the xtrace of their execution was lost
  100.  
  101. Product(s) Red Hat Enterprise Linux Component bash Category Troubleshoot Tags shells
  102. 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