Bash Echo Write Error Interrupted System Call
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies
Script Write Error Interrupted System Call
of this site About Us Learn more about Stack Overflow the company bash echo write error invalid argument Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users interrupted system call linux Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Bash file descriptor leak up vote 4 down vote favorite 4 I get a file descriptor leak when running the following code: function get_fd_count() { local fds cd /proc/$$/fd; fds=( * ) # avoid a StackOverflow source colorizer bug echo "${#fds[@]}" } function fd_leak_func() { while : ; do echo ">> Current FDs: $(get_fd_count)" read retval new_state < <(set +e; new_state=$(echo foo); retval=$?; printf "%d %s\n" $retval $new_state) done } fd_leak_func Tested on both 3.2.25 and 4.0.28. This only happens when the loop is happening within a function; every time we return to top-level context, the extra file descriptors are closed. Is this intended behavior? More to the point, are workarounds available? Followup: After reporting to the bash-bug mailing list, this was confirmed as a bug. Chet indicated that a fix will be included in the next release (as of 4/17/2010). bash share|improve this question edited Apr 19 '10 at 10:53 asked Apr 15 '10 at 21:51 Charles Duffy 94.5k15102142 Even weirder, if I put a true at the end of the loop it keeps going up, but putting a /bin/true keeps it level at 5. –Ignacio Vazquez-Abrams Apr 15 '10 at 23:17 Report it to the newsgroup using the bashbug program and see what the maintainer, Chet Ramey, says about it. –Dennis Williamson Apr 16 '10 at 0:40 Still leaks in CentOS 6 bash 4.1.2(1)-release. –clacke Mar 4 '13 at 8:52 Adding
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Unix & Linux Questions Tags Users Badges Unanswered Ask Question _ Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute: Sign up Here's how it works: Anybody can ask a question Anybody can answer The best answers http://stackoverflow.com/questions/2649240/bash-file-descriptor-leak are voted up and rise to the top Occasional error from bash on AIX: Interrupted system call up vote 0 down vote favorite I am experiencing problems with process substitution in bash on AIX It happens very rarely, apparently only when the server is loaded. An example error message is: line 9: /tmp//sh-np-7841523: Interrupted system call Before I investigate more into my script, I wanted to know if you had already had http://unix.stackexchange.com/questions/102784/occasional-error-from-bash-on-aix-interrupted-system-call issues with process substitution. Or get your inputs regarding some possible recommendations to observe when implementing process substitution. Note: this simple script can generate the aforementioned error: #!/bin/bash read var < <(echo) However I stress this point: the error is very rare. It cannot be reproduced systematically. The server on which the script has been tested is a production server. bash aix system-calls process-substitution share|improve this question edited Apr 27 at 18:27 Anthon 47.4k1462125 asked Nov 27 '13 at 15:15 Brat PID 112 2 We can't answer unless you show us what kind of process substitution you run, if you get this error every time you do a process substitution or only with certain commands etc. –terdon♦ Nov 27 '13 at 15:25 add a comment| 1 Answer 1 active oldest votes up vote 2 down vote Check that you're using the latest version of bash. If you are, report a bug; be sure to indicate exactly where you obtained the bash binary if you installed an existing binary, or what compiler and compile-time configuration you used and where you obtained the source if you compiled bash by yourself. Also mention your exact version of AIX and your hardware architecture. Mention how to reproduce the bug, like you did here, of course. “In
coprocess Date: Wed, 24 Mar 2010 20:30:00 +0100 User-agent: KMail/1.13.1 (Linux/2.6.32.9-70.fc12.x86_64; KDE/4.4.1; x86_64; ; ) Configuration Information [Automatically generated, do not change]: Machine: x86_64 OS: linux-gnu Compiler: gcc Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64' - DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-unknown-linux-gnu' - DCONF_VENDOR='unknown' https://lists.gnu.org/archive/html/bug-bash/2010-03/msg00090.html -DLOCALEDIR='/home/trnka/opt/share/locale' - DPACKAGE='bash' -DSHELL -DHAVE_CONFIG_H -I. -I. -I./include -I./lib -g - O2 uname output: Linux a324-2 2.6.24.2 #1 SMP Wed Feb 20 12:36:17 CET 2008 x86_64 GNU/Linux Machine Type: x86_64-unknown-linux-gnu Bash Version: 4.1 Patch Level: 2 Release Status: release Description: I've started using coprocesses heavily and I've found a nasty problem related (but not limited) to them: After the coprocess finishes its job, the resultant write error SIGCHLD is not properly blocked by bash signal processing logic and interferes with script I/O. In my case, I've been using something like: read var1 var2 < <( a | long | pipeline | here) echo "var1=$var1" echo "var2=$var2" Sometimes, the SIGCHLD arrived just when one of the echos were doing output and the result was: echo: write error: Interrupted system call As this is a interrupted system call bit of a race, it occurs only when the stars are right, i.e. during normal usage the probability of the SIGCHLD hitting exactly the echo is quite low. However, as soon as anything causes the I/O to take significantly longer, the bug appears. I've been hitting quite often (30%?) when running the script over SSH. This bug has probably been reported years ago here: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=382798 Repeat-By: I've reduced one of my scripts to this (nothing exceptionally intelligent, but it does the job): #!/bin/bash while [[ 1 ]]; do set +e read tmp tmp2 < <( echo "blabla" | wc | tr -s " " "\n" | tail -n 2 | tr "\n" " ") set -e echo $tmp echo $tmp2 echo $tmp echo $tmp2 echo $tmp echo $tmp2 echo $tmp echo $tmp2 echo $tmp echo $tmp2 echo $tmp echo $tmp2 echo $tmp echo $tmp2 echo $tmp echo $tmp2 echo $tmp echo $tmp2 done Using this script I can reliably reproduce the bug (i.e. get a Interrupted system call error) using bash 4.1.2 (compiled myself from vanilla tarball) and 3.1.17 (Debian lenny) over SSH and 4.0.35 (stock Fedora 12) under strace. Fix: Applying the following simpl